9

I am working in an Objective-C, iOS project, I used danielgindi Charts library which is a Swift library. I downloaded it using Cocoapods.

I am trying to import the library files into my Objective-C files using 'projectName-Swift.h' as mentioned in this question but I faced an error:

'projectName-Swift.h' file not found

2
  • Did you checked usage section of Charts lib? When using Swift in an ObjC project: You need to import your Bridging Header. Usually it is "YourProject-Swift.h", so in ChartsDemo it's "ChartsDemo-Swift.h". Do not try to actually include "ChartsDemo-Swift.h" in your project :-) Under "Build Options", mark "Embedded Content Contains Swift Code" Commented May 28, 2016 at 19:54
  • @DavidV I noticed this and imported 'myprojectName-Swift.h' and I set "Embedded Content Contains Swift Code" to yes. I faced the same issue Commented May 28, 2016 at 20:27

3 Answers 3

10

If you have installed Swift library using cocoapods

To import Library in Objective C Code Use in Objective C

@import frameworkname;

In Swift

@import frameworkname
Sign up to request clarification or add additional context in comments.

Comments

1

If your using cocoa pods try to make sure you have use_frameworks! in your cocoa pods pod file, otherwise the Swift Framework wont work. Also look at this for any other issues that may pop up: link

1 Comment

The swift framework has to explicitly support Objective C as is mentioned here stackoverflow.com/questions/31099596/… Could this be your problem?
1

For making the bridging header visible to your compiler you need a little setup

  1. Go to your Project Build Settings
  2. Search for bridging header
  3. Add the path to your .h file (usually ProjectName/ProjectName-Swift.h)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.