我的静态库是用 xcodebuild 构建的,然后从模拟器和设备构建结果创建一个胖库。这是我的 xcodebuild 命令:
xcodebuild OTHER_CFLAGS="-fembed-bitcode" -configuration "iphoneos" -target "${LIB_NAME}Common" -sdk iphoneos
xcodebuild OTHER_CFLAGS="-fembed-bitcode" -configuration "iphonesimulator" -target "${LIB_NAME}Common" -sdk iphonesimulator
脂命令:
lipo -create "${DEVICE_DIR}/lib${LIB_NAME}Common.a" "${SIMULATOR_DIR}/lib${LIB_NAME}Common.a" -output "${INSTALL_DIR}/include/${LIB_NAME}/lib${LIB_NAME}Common.a"
在检查了 fat lib 中的架构后,我得到了:
$ lipo -info MyLibCommon.a
Architectures in the fat file: MyLibCommon.a are: armv7 i386 x86_64 arm64
但是,当我通过 cocoapods 将 lib 添加到项目中并在模拟器上的 Apple 新 Silicon(带有 arm64 芯片组)上运行该项目时,出现以下编译错误:
building for iOS Simulator, but linking in object file built for iOS, file 'MyLibCommon.a' for architecture arm64
排除模拟器的 arm64 架构不是一种选择,因为在 Apple Silicon Mac 上具有 arm64 芯片组。
知道如何为 Apple Silicon Simulator 构建静态库吗?