我正在尝试编译一个C库,以便在我的iOS项目中使用它,并且我想嵌入bitcode。
我可以成功地构建针对每个拱形的静态库。这些静态库确实包含bitcode (使用otool进行检查),但是动态库不包含bitcode。为什么?是dylib?中不支持的位代码。
我要构建的库是xz。这是剧本
build_iOS()
{
ARCH=$1
if [ $ARCH == "i386" ] || [ $ARCH == "x86_64" ];
then
SDKROOT="$(xcodebuild -version -sdk iphonesimulator | grep -E '^Path' | sed 's/Path: //')"
else
SDKROOT="$(xcodebuild -version -sdk iphoneos | grep -E '^Path' | sed 's/Path: //')"
fi
export CC="$(xcrun -sdk iphoneos -find clang)"
export CFLAGS="-fembed-bitcode -isysroot $SDKROOT -arch ${ARCH} -miphoneos-version-min=9.0"
export LDFLAGS="-arch ${ARCH} -isysroot $SDKROOT"
if [ $ARCH == "i386" ] || [ $ARCH == "x86_64" ];
then
./configure --prefix=$XZPATH/build/iOS/$ARCH --host=i686-apple-darwin11 --disable-static --enable-shared
else
./configure --prefix=$XZPATH/build/iOS/$ARCH --host=arm-apple-darwin --disable-static --enable-shared
fi
make && make install && make clean
}
build_iOS i386
build_iOS x86_64
build_iOS armv7
build_iOS armv7s
build_iOS arm64谢谢!
发布于 2016-08-12 17:48:10
看来我不能将bitcode添加到dylibs中。我试着构建了几个dylib,然后使用otool -l path_to_dylib | grep bitcode测试它们是否包含任何bitcode,它们都一无所获。
更多证据:
目前我不知道为什么macOS应用程序在构建设置中没有启用bitcode选项。也许是因为Mac不是分发mac应用程序的唯一途径?人们可能会使用USB接口将一个mac应用程序从一个mac应用复制到另一个mac应用程序?
发布于 2016-09-01 18:11:17
我无法通过cmd行工具(otool、file或clang)在我的bitcode启用的动态库中验证bitcode。此外,比较bitcode和非bitcode构建之间的差异,除了文件大小之外,没有显示出任何差异。
有趣的是,当使用动态库时,当我使用非bitcode构建时,在实际的应用程序中启用并存档xcode的动态库将失败:
ld: bitcode bundle could not be generated because '...' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build for architecture armv7当使用启用bitcode构建dylib时,文件大小会大幅度增加,而且xcode也不会在启用bitcode的示例项目存档时失败。所以我很确定bitcode必须包含在动态库中,尽管我们还没有找到通过cmd行工具来验证这一点的方法.
https://stackoverflow.com/questions/37262262
复制相似问题