How to mix Swift and Objective-C in pod lib?

I created a new swift lib pod using the command: pod lib create MixSwiftObjectiveC, found from https://guides.cocoapods.org/making/using-pod-lib-create.html

In this lib folder, I need to use code written in Objective-C. If I had a separate “normal” project, I would just include the import in the header file ... -Bridging-Header.h. Is there an equivalent for pod lib? Can Swift and Objective-C be mixed inside pod lib?

As an example, I created this github: https://github.com/crarau/MixSwiftObjectiveC To run the example, you will need Xcode Version 7.0 beta 6 and Swift 2.0

Compilation problem

Thank you for your help!

+4
1

, :

  • iOS 8+ (...)
  • Xcode Cocoa Touch Framework
  • , objc . , , public. documentation
  • podspec, (. , ). , Umbrella Header ( objc) source_files podspec. Xcode . NVMDummy, NVMDummy.h.
  • .
  • pod lib. , pod lib ViewController.m, :

    @import MyPodLibMixingOjbcAndSwift;
    
    // in viewDidLoad
    // use objc code in MyLib -> OK...
    // use swift code in MyLib -> OK...
    

- , .

: https://github.com/axl411/TestNVMDummy

+3

Source: https://habr.com/ru/post/1606420/


All Articles