iOS: 何时选择 Cocoa Touch 静态库或框架?

iOS: When to choose a Cocoa Touch Static Library or Framework?

首先:我在这里阅读了其他问题,但他们说例如Swift 不能在框架 or/and 库中使用或已过时(5 岁)。

Cocoa Touch Framework 与 Cocoa Touch Static Library 的优缺点是什么?

我正在尝试在两个 iOS 目标之间共享代码,例如一个 iPhone 目标和一个 iPad 目标(此处不需要通用目标)。

如果我没理解错的话,静态库和应用程序代码将合并为一个二进制文件,而框架和应用程序代码合并为两个二进制文件。我想这意味着要将更多签名和更多 DSYM 文件上传到崩溃报告工具?

另外,框架 should/could 也可以独立工作,而静态库总是需要其他代码。

测试、App Store 分发、调试(断点)和编译时间如何?哪个选项对哪个任务执行得更好?

静态与动态框架的一些说明:

语言:至于Swift的使用,以前不能用它创建静态库,但是从Xcode9开始就可以了。所以我想 Swift vs. ObjC 不会有问题。还没有找到任何关于使用 Swift 创建静态库的教程,只是为了创建框架(例如:https://www.raywenderlich.com/5109-creating-a-framework-for-ios)。因此,就查找 resources/references.

而言,框架可能会更容易

dSYM:引用 Apple 员工的回答:"If you are building the framework as a dependency of your app target, the dSYMs for the framework will be present in the archive you create when archiving the app for distribution. If you are using a framework provided by a vendor that is already compiled, you will need to contact the framework vendor about the dSYMs." (https://forums.developer.apple.com/thread/70716). As for Static Libraries, they would be less work in terms of the dSYMs you handle. ()

框架协同设计:"Developer is free to distribute iOS framework without codesigning it as Consumer will re-codesign it anyway, but Developer is forced by Xcode to codesign their framework when they build for iOS device" ()

至于测试,在单元测试目标的构建阶段添加框架或静态库应该可以完成工作。

断点: 静态库:Debugging a static library in Xcode 框架:

就我在链接中读到的内容而言,虽然静态库可能更高效一些,但框架的设置工作要少得多。