项目里用到了两包管理器,Cocoapods 和 Carthage 都用到了,感觉有点混乱,问了下说是优化编译速度所采取的措施,那为什么不都用 Carthage 或者 Cocoapods 有没有好的处理方式或者其他更好的方法?
名词
- 静态库 Static Libraries -
.a
。As the name says, they are static. So they are already compiled, when you import them to your project. You can share them with others without showing them your code. Note that Static Libraries currently don’t support Swift. You will have to use Objective-C within the library. The app itself can still be written in Swift. - 动态库 —
.dylib
- framework。They are always open-source and will be built just like your app. (So Xcode will sometimes compile it, when you run your app and always after you cleaned the project.) Frameworks only support iOS 8 and newer, but you can use Swift and Objective-C in the framework.
- xcframework
- 预编译 pre-compile
包管理器
Cocoapods
use_frameworks!
tells CocoaPods that you want to use Frameworks instead of Static Libraries. Since Swift does not support Static Libraries you have to use frameworks.
插件
cocoapods-binary已经不更新了,试了下没成功,但是大体知道原因,应该是三方库本身不支持framework导致找不到header?
Rome已经不更新了,从这里找到了下面这个;
cocoapods-binary-cache可以使用,第一次完成后build time减少50%。
cocoapods-binary
如果想重新生成 binary,执行下面两句 |
Swift package manager
// Xcode 13 "Missing package product" using local Swift Packages |
参考
When in Rome: How Spotify halved build times with just one script
Using CocoaPods to just build frameworks for use elsewhere
Swift Package Manager and How to Cache It with CI
Analyzing and Improving Build times in iOS
浅析 Cocoapods-Packager 实现