iOS 编译包含 bitcode 的 opencore-amr-iOS 静态库

  1. 下载 opencore-amr-iOS 源码。
  2. 修改 build_ios_xcode6.sh 脚本,-fembed-bitcode-marker 为新增的内容。
  3. #!/bin/sh
    
    set -xe
    
    VERSION="0.1.3"
    SDKVERSION="9.2"
    LIBSRCNAME="ios-opencore-amr"
    
    CURRENTPATH=`pwd`
    
    mkdir -p "${CURRENTPATH}/src"
    cd "${CURRENTPATH}/"
    
    DEVELOPER=`xcode-select -print-path`
    DEST="${CURRENTPATH}/lib-ios"
    mkdir -p "${DEST}"
    
    ARCHS="armv7 armv7s arm64 i386 x86_64"
    # ARCHS="armv7"
    LIBS="libopencore-amrnb.a libopencore-amrwb.a"
    
    DEVELOPER=`xcode-select -print-path`
    
    for arch in $ARCHS; do
    case $arch in
    arm*)
    
    IOSV="-miphoneos-version-min=7.0"
    if [ $arch == "arm64" ]
    then
    IOSV="-miphoneos-version-min=7.0"
    fi
    
    echo "Building for iOS $arch ****************"
    SDKROOT="$(xcrun --sdk iphoneos --show-sdk-path)"
    CC="$(xcrun --sdk iphoneos -f clang)"
    CXX="$(xcrun --sdk iphoneos -f clang++)"
    CPP="$(xcrun -sdk iphonesimulator -f clang++)"
    CFLAGS="-isysroot $SDKROOT -arch $arch $IOSV -isystem $SDKROOT/usr/include -fembed-bitcode"
    CXXFLAGS=$CFLAGS
    CPPFLAGS=$CFLAGS
    export CC CXX CFLAGS CXXFLAGS CPPFLAGS
    
    ./configure \
    --host=arm-apple-darwin \
    --prefix=$DEST \
    --disable-shared --enable-static
    ;;
    *)
    IOSV="-mios-simulator-version-min=7.0"
    echo "Building for iOS $arch*****************"
    
    SDKROOT=`xcodebuild -version -sdk iphonesimulator Path`
    CC="$(xcrun -sdk iphoneos -f clang)"
    CXX="$(xcrun -sdk iphonesimulator -f clang++)"
    CPP="$(xcrun -sdk iphonesimulator -f clang++)"
    CFLAGS="-isysroot $SDKROOT -arch $arch $IOSV -isystem $SDKROOT/usr/include -fembed-bitcode"
    CXXFLAGS=$CFLAGS
    CPPFLAGS=$CFLAGS
    export CC CXX CFLAGS CXXFLAGS CPPFLAGS
    ./configure \
    --prefix=$DEST \
    --disable-shared
    ;;
    esac
    make > /dev/null
    make install
    make clean
    for i in $LIBS; do
    mv $DEST/lib/$i $DEST/lib/$i.$arch
    done
    done
    
    for i in $LIBS; do
    input=""
    for arch in $ARCHS; do
    input="$input $DEST/lib/$i.$arch"
    done
    lipo -create -output $DEST/lib/$i $input
    done


  4. 经过测试发现,如果使用 -fembed-bitcode-marker 这一编译参数编译的话在 Archive 的时候回遇到如下错误:

所以正确的编译方式是添加 -fembed-bitcode 选项进行编译。


参考链接:



发布了170 篇原创文章 · 获赞 332 · 访问量 141万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览