Using cocoapods without use_frameworks! in swift

瘦欲@ 提交于 2019-12-10 13:43:49

问题


According to this tutorial, we should add use_frameworks! to Podfile in Swift project. But how to use third-party code in .m in the same project?

One possible way is,

  • Do NOT add use_frameworks! to Podfile
  • Import header in ...-Bridging-Header.h
  • Then, I can use third-party code in both .swift and .m file

But when I try to import header in ...-Bridging-Header.h, it just throw *.h file not found error, how to fix this issue?


回答1:


Past

Up to CocoaPods 1.4.x (included), it was NOT possible to use CocoaPods with Swift code without use_frameworks!.

Present: 1.x.x and above

Nowadays, with CocoaPods 1.x.x (I verified it with 1.4.0), it's common to use use_frameworks! for both Swift and ObjC projects: it allows for a mix of the two languages in any way you want without issues:

  • You'll be able to use a Swift dependency in an Objective-C project.
  • You'll be able to use an Objective-C dependency in a Swift project.

Present: 1.5.x and above

Nowadays, CocoaPods 1.5.0 supports integrating swift pods as static libraries. Try it (sudo gem install cocoapods) and enjoy removing use_frameworks! from your Podfile.


Note that for iOS:

  • Apple requires Xcode 10.1 minimum, which is only well supported starting CocoaPods 1.6.0, so don't bother using older versions of CocoaPods.
  • Apple will require Xcode 11 minimum in April 2020, for which I would only use CocoaPods 1.7.5 or newer, together with xcodeproj 1.13.0 or newer.


来源:https://stackoverflow.com/questions/33492873/using-cocoapods-without-use-frameworks-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!