Reputation: 2862
I have an existing project which is written in Objective-C. I want to use the iOS Charts library by Daniel Gindi, which is in Swift, in that project. How can I achieve this?
importing swift framework into a objective-c project is related, but in my case I am using the library by installing it through Cocoapods as instructed here.
In that question, he is at least able to import the header, but in my case I am not able to.
step 1: Create Objective-C single view project.
step 2: Create a Podfile and add following lines -
use_frameworks!
pod 'Charts'
step 3: Install the pod
step 4: Try to import Charts in ViewController.h by @import Charts
but it gives an error at this point. The error is - Module Charts not found
Upvotes: 12
Views: 15737
Reputation: 140
I found the reason why it works for new project, but for an existing project.
In the project settings, delete the value of the Other Linker Flags property.
This is the most case that most developers are being missed.
Upvotes: 0
Reputation: 2026
I tried the same step what you mentioned in the comment however I was not getting the error that you got. My project simply builds and runs. Steps that I followed:
use_frameworks! pod 'Charts'
'pod install'
command from the termial
#import "ViewController.h" @import Charts;
Upvotes: 7
Reputation: 2862
In my existing project, I did #include Charts-Swift.h
in my project's main.m
file and this solved problem from me. @import Charts
worked perfectly now. This was done according to the instructions that are written in Apple documentation here.
I made a new project and tried Anni S's answer, this time I built the project with cmd+B
before writing any import statement and it worked too. I guess building it once after installing pod and before importing any module is necessary.
Upvotes: 10