将静态库目标转换为 Xcode 项目中的框架目标 [英] Convert a static library target into a framework target in an Xcode project

查看:30
本文介绍了将静态库目标转换为 Xcode 项目中的框架目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生成静态库的 Xcode 项目.我的团队计划在 Swift 中进行所有新的开发.无法将 Swift 文件添加到静态库项目.我们正在放弃对 iOS 7 的支持,因此现在可以在我们的 iOS 应用程序中包含框架.因此,我打算将我的静态库项目转换为框架项目.

I have a an Xcode project which produces a static library. My team plans all new development in Swift. It is not possible to add Swift files to the static library project. We are dropping support for iOS 7, so it is now possible to include frameworks in our iOS app. Therefore, I intend to convert my static library project to a framework project.

我已经查看过,但找不到任何有关如何执行此转换的工具或建议.静态库很大(超过 100 个 .m 文件).

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).

我希望得到比创建新的并行框架目标更好的答案.我已经尝试过两次了.第一次作为 swift 目标,但我无法轻松导入所有 Objective C 文件.接下来,作为 Objective C 目标,但不再有 .pch.

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. Next, as an Objective C target, but there is no .pch anymore.

推荐答案

从静态链接库转换静态/动态链接框架,

To convert the static/dynamic linked framework from static linked library,

  1. 在您现有的静态链接库项目中添加一个新的 cocoa touch 框架作为 TARGET.
  2. 在构建阶段,将所有 .m、.mm、.c、.cpp、.metal 等添加到静态链接框架目标的Build PhasesCompile Sources"阶段.
  3. 将要公开的标头放入Build PhasesHeaders".
  4. 对于动态链接框架,请记住检查您的构建设置中的 Mach-O 类型设置.如果要使用 swift,则需要确保将 Mach-O 类型设置为动态库,以便它成为动态链接框架.对于静态链接框架,您需要将Mach-O类型设置为静态库,但是您不能在转换后的静态链接框架中使用swift(仅允许objective-c、objective-c++、C++、C等).

然后,对于想要使用此框架的应用程序,只需将标头包含为#import 并将框架添加到您的应用程序目标的Build PhasesLink Binary With Libraries"中.如果转换后的框架是动态链接框架,则需要将其放入Embedded Binaries"中.

Then for the app that wants to use this framework just need to include the headers as #import and add the framework into "Build PhasesLink Binary With Libraries" of your App Target. If the converted framework is dynamic linked framework, you will need to put it into "Embedded Binaries".

这篇关于将静态库目标转换为 Xcode 项目中的框架目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆