问题描述
我正在尝试为我正在使用的几个第三方库创建一个 .xcframework
文件.按照 https://appspector.com/blog/xcframeworks 的说明,我
I am trying to create an .xcframework
file for a few third party libraries I'm using. Following the instructions from https://appspector.com/blog/xcframeworks, I
- 创建特定于平台的
framework
文件:
此时,我已经获得了两个带有 .swiftmodule
文件的框架;一切看起来都很好.框架确实不带有 .swiftinterface
文件,但我认为没关系,因为这些是 objc 项目.那么,我
At this point, I've gotten two frameworks with .swiftmodule
files; everything looks good. The frameworks do not come with .swiftinterface
files, but I think that is alright as these are objc projects. Then, I
- 将各个
framework
组合成一个单独的xcframework
文件:
- Combine the individual
framework
s to form a singlexcframework
file:
这里,xcodebuild
没有失败,但它会发出一个奇怪的错误:
Here, xcodebuild
doesn't fail, but it emits a curious error:
至关重要的是,.xcframework
包不包含 Info.plistframework
的 或 文件夹代码>文件.显然,当我尝试在这种状态下链接到 xcframework
时,我会收到一堆缺少符号"链接器错误.
Crucially, the .xcframework
package does not contain the individual framework
s or folders specified in the Info.plist
file. Obviously, when I try to link to the xcframework
in this state, I get a bunch of "missing symbols" linker errors.
这是为什么?我必须怎么做才能让 xcodebuild
完全创建 xcframework
?
Why is this? What must I do to get xcodebuild
to create the xcframework
completely?
注意:目前手动创建文件夹似乎可行,但这感觉不对而且很脆弱——Apple 可以随时更改 xcodebuild
的工作方式.
NB: Manually creating the folders seems to work for now, but this feels wrong and is brittle – Apple can change the way xcodebuild
works anytime.
推荐答案
原来在 xcodebuild
命令的末尾添加 BUILD_LIBRARY_FOR_DISTRIBUTION = YES
是不够的/不是努力使用所需的 swiftinterface
文件生成框架.我必须进入实际项目的设置并手动将 BUILD_LIBRARY_FOR_DISTRIBUTION
设置为 YES
,例如 这个答案 建议.在我得到带有 swiftinterface
文件的框架后,我就能够使用 xcodebuild
创建 xcframework
文件而没有任何问题.
Turns out that adding BUILD_LIBRARY_FOR_DISTRIBUTION = YES
to the end of the xcodebuild
command was not enough / not working to produce a framework with the required swiftinterface
files. I had to go in the settings for the actual project and manually set BUILD_LIBRARY_FOR_DISTRIBUTION
to YES
, like this answer suggests. After I got the frameworks with the swiftinterface
files, I was then able to create the xcframework
file using xcodebuild
without any problems.
这篇关于xcframework 不包含内部框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!