2

Right now Cocoapods supports Swift, and I can make a Cocoapod based on Swift code and get it working.

But in one scenario the Swift code need to use an Objective C class defined in another Cocoapod. I added the dependency in the podspec, and in the main project both the swift pod and the Objective C pod are installed, but the compiler complains about undeclared type on the line where the Swift code is referencing the Objective C class. I added the Objective C header in the main project's bridging-header.h, and it works when i use that class in the swift files in the main project, but the in the Swift cocoapod it doesn't.

I also tried to add a {project name}-Bridging-Header.h file in the Swift cocoapod, and imported the Objective C header, and it still doesn't work.

Is it possible to let a Swift cocoapod depend on an Objective C cocoapod now? Am I doing something incorrect?

Bao Lei
  • 3,515
  • 3
  • 19
  • 17
  • I think it's similar but slightly different from this question: http://stackoverflow.com/questions/24248975/combining-swift-and-objective-c-in-a-cocoapod?rq=1 But there's no working answer yet. – Bao Lei Feb 20 '15 at 05:04
  • Can you post both the `Podfile` and the `podspec`? – fz. Feb 20 '15 at 05:56
  • Thanks fz. Actually i was using a wrong version of cocoapods before (did gem install cocoapods --pre but gem was still at 0.35.0) and now I fixed it by doing bundle exec gem install cocoapods. Now I am actually at 0.36.0, and I'm seeing a new issue: the APIs from cocoa pods don't even work in the main project any more. Here is my pod: https://github.com/ba01ei/playground Here is how I added the pod: pod 'playground', :git => 'git@github.com:ba01ei/playground.git', :tag => '0.0.0' Here's my error: https://www.dropbox.com/s/9048x38yfpmhuuc/Screenshot%202015-02-21%2014.06.18.png?dl=0 – Bao Lei Feb 21 '15 at 22:04
  • To provide more info, here my bridging header: https://www.dropbox.com/s/02ja1trzbpbpbv7/Screenshot%202015-02-21%2014.11.25.png?dl=0 this is my pod file: https://www.dropbox.com/s/f8qstzptmy5jpuq/Screenshot%202015-02-21%2014.12.02.png?dl=0 I can upload the whole project to github if necessary but i guess this is already enough info. Really appreciate your help fz :) – Bao Lei Feb 21 '15 at 22:12

0 Answers0