我正在构建一个 iOS 静态库,我想为 bitcode 提供支持。为了实现这一点,我进入构建设置,搜索“自定义编译器标志”并添加 -fembed-bitcode。这将使用位码构建库,并且在 XCode 7 下一切正常。
但是,按照上面的方法,我失去了与 XCode 6 的向后兼容性。话虽如此,我必须向我的用户提供 2 个不同的库版本,一个带有位码标志,一个没有,因为不是每个人都升级到 XCode 7。
有没有办法让启用位码的库并具有向后兼容性而不必发布 2 个不同的版本?
更新:
你好@Vinicius Jarina 谢谢你的留言。我知道您可以创建一个胖库,我想这是一种常见的做法。到目前为止,我所做的是为这两种架构构建:
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdK iphoneos
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator
然后调用 lipo 打包到一个胖库中,例如:
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}"
但是,我现在该怎么做?我根据这个链接尝试了这样的事情,但没有运气:
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator
xcodebuild -configuration "Release" OTHER_CFLAGS='-fembed-bitcode' -target "${FMK_NAME}" -sdk iphonesimulator
xcodebuild -configuration "Release" OTHER_CFLAGS='-fembed-bitcode' -target "${FMK_NAME}" -sdk iphoneos
然后像这样创建一个胖库:
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}"
如何在我的 scipt 中构建以包含两者,然后将它们打包到胖库中?
更新 2:
我终于设法完成了这项工作,并在这里列出了我的解决方案,供可能面临相同问题的其他人使用:
xcodebuild -configuration "Release" ENABLE_BITCODE=NO -target "${FMK_NAME}" -sdK iphoneos
xcodebuild -configuration "Release" ENABLE_BITCODE=NO -target "${FMK_NAME}" -sdk iphonesimulator
xcodebuild -configuration "Release" ENABLE_BITCODE=YES -target "${FMK_NAME}" -sdk iphonesimulator
xcodebuild -configuration "Release" ENABLE_BITCODE=YES -target "${FMK_NAME}" -sdk iphoneos
然后像这样创建一个胖库:
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}"