我在脚本文件中编写了以下命令,为 iPhoneSimulator 和 iPhoneOS 创建 XCFrameworks,如下所示:
xcodebuild archive -scheme "ProjectD" -archivePath "/Users/Ron/Archives/ProjectDiphoneSimulator.xcarchive" -sdk 'iphonesimulator' SKIP_INSTALL=NO
xcodebuild archive -scheme "ProjectD" -archivePath "/Users/Ron/Archives/ProjectDiphoneOS.xcarchive" -sdk 'iphoneos' SKIP_INSTALL=NO
xcodebuild -create-xcframework -framework "/Users/Ron/Archives/ProjectDiphoneSimulator.xcarchive/Products/Library/Frameworks/ProjectDiphoneSimulator.framework" -output "/Users/Ron/XCFrameworks/ProjectDiphoneSimulator.xcframework"
xcodebuild -create-xcframework -framework "/Users/Ron/Archives/ProjectDiphoneOS.xcarchive/Products/Library/Frameworks/ProjectDiphoneOS.framework" -output "/Users/Ron/XCFrameworks/ProjectDiphoneOS.xcframework"
在将其拖放到嵌入式框架和库后,我尝试在项目中使用它
当我以设备为目标运行项目时,它工作正常。但是当我在模拟器上运行它时,它会抛出以下错误:
在为 iOS 模拟器构建时,在/Users/Ron/XCFrameworks/ProjectD.xcframework中找不到库
如果我更改存档和 XCFramework 创建的顺序,如下所示:
xcodebuild archive -scheme "ProjectD" -archivePath "/Users/Ron/Archives/ProjectDiphoneOS.xcarchive" -sdk 'iphoneos' SKIP_INSTALL=NO
xcodebuild archive -scheme "ProjectD" -archivePath "/Users/Ron/Archives/ProjectDiphoneSimulator.xcarchive" -sdk 'iphonesimulator' SKIP_INSTALL=NO
xcodebuild -create-xcframework -framework "/Users/Ron/Archives/ProjectDiphoneOS.xcarchive/Products/Library/Frameworks/ProjectDiphoneOS.framework" -output "/Users/Ron/XCFrameworks/ProjectDiphoneOS.xcframework"
xcodebuild -create-xcframework -framework "/Users/Ron/Archives/ProjectDiphoneSimulator.xcarchive/Products/Library/Frameworks/ProjectDiphoneSimulator.framework" -output "/Users/Ron/XCFrameworks/ProjectDiphoneSimulator.xcframework"
它适用于模拟器,而不适用于具有相同错误的设备:
在为 iPhone 构建时,在/Users/Ron/XCFrameworks/ProjectD.xcframework中找不到库
我也将Build Libraries for Distribution设置为Yes。如果我尝试使用不同的目的地创建它们(iPhone 和模拟器的 2 个 XCFrameworks)它正在工作。但这实际上违背了 XCFrameworks 的目的。
我是否遗漏了什么或做错了什么步骤?感谢您提前回答。