xcframework不包含内部框架 [英] xcframework does not contain internal frameworks
问题描述
我正在尝试为我正在使用的一些第三方库创建一个 .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
文件:
# Archive for device
xcodebuild archive -scheme TestFramework -destination="iOS" -archivePath /tmp/xcf/ios.xcarchive -derivedDataPath /tmp/iphoneos -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
# Archive for simulator
xcodebuild archive -scheme TestFramework -destination="iOS Simulator" -archivePath /tmp/xcf/iossimulator.xcarchive -derivedDataPath /tmp/iphoneos -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
在这一点上,我已经获得了两个带有 .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:
# Build xcframework with two archives
xcodebuild -create-xcframework -framework /tmp/xcf/ios.xcarchive/Products/Library/Frameworks/TestFramework.framework -framework /tmp/xcf/iossimulator.xcarchive/Products/Library/Frameworks/TestFramework.framework -output /tmp/xcf/TestFramework.xcframework
在这里, xcodebuild
不会失败,但是会发出一个奇怪的错误:
Here, xcodebuild
doesn't fail, but it emits a curious error:
No 'swiftinterface' files found within '/Users/user/git/ReactiveObjC/output/xcf/ios.xcarchive/Products/Products/Library/TestFramework.framework/Modules/TestFramework.swiftmodule'.
至关重要的是, .xcframework
包不包含在 Info.plist 中指定的各个
framework
的或文件夹.代码>文件.显然,当我尝试以这种状态链接到 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.
这是为什么?要完全创建 xcframework
,我该怎么做才能获得 xcodebuild
?
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
,例如
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不包含内部框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!