[英]Convert a static library target into a framework target in an Xcode project
I have a an Xcode project which produces a static library. 我有一个Xcode项目,它生成一个静态库。 My team plans all new development in Swift. 我的团队计划在Swift中进行所有新开发。 It is not possible to add Swift files to the static library project . 无法将Swift文件添加到静态库项目中 。 We are dropping support for iOS 7, so it is now possible to include frameworks in our iOS app. 我们正在放弃对iOS 7的支持,因此现在可以在我们的iOS应用程序中包含框架。 Therefore, I intend to convert my static library project to a framework project. 因此,我打算将我的静态库项目转换为框架项目。
I have looked but I cannot find any tools or advice for how to perform this conversion. 我看过,但我找不到任何有关如何执行此转换的工具或建议。 The static library is large (more than 100 .m files). 静态库很大(超过100个.m文件)。
I'm hoping for a better answer than create a new parallel framework target. 我希望得到一个更好的答案,而不是创建一个新的并行框架目标。 I've attempted this twice. 我试过两次。 The first time as a swift target, but I wasn't able to easily import all the Objective C files. 第一次作为一个快速的目标,但我无法轻松导入所有的Objective C文件。 Next, as an Objective C target, but there is no .pch anymore. 接下来,作为Objective C目标,但不再有.pch。
To convert the static/dynamic linked framework from static linked library, 要从静态链接库转换静态/动态链接框架,
Then for the app that wants to use this framework just need to include the headers as #import and add the framework into "Build Phases\\Link Binary With Libraries" of your App Target. 然后,对于想要使用此框架的应用程序,只需将标头包含为#import,并将框架添加到App Target的“Build Phases \\ Link Binary With Libraries”中。 If the converted framework is dynamic linked framework, you will need to put it into "Embedded Binaries". 如果转换的框架是动态链接框架,则需要将其放入“嵌入式二进制文件”中。
I saw that someone created the framework manually, creating a module.framework file and copying all the header files in a module.framework/Headers folder. 我看到有人手动创建了框架,创建了module.framework文件并将所有头文件复制到module.framework / Headers文件夹中。 This solution seems to work, the project can import correctly the files and see them as a framework correctly. 这个解决方案似乎有效,项目可以正确导入文件并正确地将它们视为框架。
I'm not sure this is the best way to do it tough, I'm trying it on a big project that ATM is importing the static library through cocoapods, but it seems like I have some problem with the visibility of some of the classes using the framework. 我不确定这是做这件事的最好方法,我正在尝试ATM通过cocoapods导入静态库这个大项目,但似乎我对某些类的可见性有些问题使用框架。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.