pitachip
pitachip

Reputation: 965

How do I get a Swift Cocoapod working in an Objective C project?

I am trying to get the Swift Charts library for iOS working in my Objective-C project. Here's what I've done so far:

(1) Installed the Charts pod

(2) Under "Build Options", set "Embedded Content Contains Swift Code" to YES

(3) Followed the Apple doc for importing external frameworks and put '@import Charts;' in one of my .m files. I set the Defines Modules to YES in my project Target--which makes Xcode recognize the import statement. BUT the doc says to set it in the Framework--which I don't know how to access that--so that may be the problem?

I'm getting many errors popping up in files of the Charts Cocoapod itself (Things like "Expected ',' separator"), which I'm sure is not because they are actual errors (this is a well maintained library), but because something is not hooked up right. What am I doing wrong?

Upvotes: 2

Views: 1978

Answers (1)

Muhammad Awais
Muhammad Awais

Reputation: 340

I have used ChartsPod recently in objective-c project. Yes it was headache to set up Chart Pods with the project. Few things you need to look carefully while importing swift pod.

  • Follow author instructions carefully.
  • Have you created Bridging Header to tell compiler it's a swift code? If not then read authors instructions carefully (Chart-iOS) or read BridgingHeader

  • In Target->Build Phases->Target Dependencies add Chart-iOS

Hope this will help.

Upvotes: 2

Related Questions