作用
amr
是一个很适合在线传输的音频格式。但悲摧的是apple
早就不支持它了。原因不明。
另一层是微信也是使用的这种格式来录制音频。
不只apple
不支持它,万能的cocoapods
也没有支持的。只好自己动手了。
止于当前,我找到最合适的,就是opencore-amr
库。这个库12年写就。这么多年也没见怎么更新。[捂脸]😂
找到了一个好心人写的支持bitcode
和8.0的编译脚本
原料
github:opencore-amr-IOS
sourceforge:opencore-amr 0.1.3
编译脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| #!/bin/sh
set -xe
VERSION="0.1.3" SDKVERSION="8.4" LIBSRCNAME="opencore-amr"
CURRENTPATH=`pwd`
mkdir -p "${CURRENTPATH}/src" tar zxvf ${LIBSRCNAME}-${VERSION}.tar.gz -C "${CURRENTPATH}/src" cd "${CURRENTPATH}/src/${LIBSRCNAME}-${VERSION}"
DEVELOPER=`xcode-select -print-path` DEST="${CURRENTPATH}/lib-ios" mkdir -p "${DEST}"
ARCHS="armv7 armv7s arm64 i386 x86_64"
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
|
编译方式
1 2 3 4 5 6 7 8 9 10
| > mkdir opencore-amr > cd opencore-amr > > ls build.sh opencore-amr-0.1.3.tar.gz > bash build.sh > ..... > > ls build.sh lib-ios opencore-amr-0.1.3.tar.gz src
|