1.修改路径webrtc/src/tools_webrtc/ios/build_ios_libs.py文件的cpu架构python
DEFAULT_ARCHS = ENABLED_ARCHS = ['arm64','arm','x64','x86']
复制代码
2.直接运行命令--bitcode
是开启bitcode功能,若是开启会致使生成的freamwork很是的大。因此通常不增长,切换到目录webrtc/src/tools_webrtc/ios
linux
python build_ios_libs.py
复制代码
3.最后输出的WebRTC.framework
在webrtc/src/out_ios_libs
目录下.android
若是遇到只要部分cpu架构能够本身进行删除控制。
Note: 若是你的freamwork只有armv7 和 arm64架构,可是在你上传到App Store或者pod trunk 须要x86_64或i386 能够在工程配置Build Phase
中的/bin/sh
增长以如下脚本进行忽略。
遇到一个比较坑的问题在build_ios_libs.py有一行将x86架构移除,建议此处将它注释掉,不然一直编译不经过支持i386架构。ios
# Ignoring x86 except for static libraries for now because of a GN build issue
# where the generated dynamic framework has the wrong architectures.
if 'x86' in architectures and args.build_type != 'static_only':
architectures.remove('x86')
复制代码
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
复制代码
1.使用gn配置生成支持 Ninja编译的配置文件。(gn相关文档地址)
gn须要配置的的主要变量有如下:web
target_os
: 目标系统有:android, ios, mac,linux,chromeos,如:iOS设置为 target_os="ios"target_cpu
: 目标cpu架构有:
- ios对应cpu有:arm,arm64,x64,x86
- android对应cpu有:arm64,x86(32位),x64(64位)
- chromeos对应有:mips64el
- linux对应:x86,x64
# debug build for 64-bit iOS
gn gen out/ios_64 --args='target_os="ios" target_cpu="arm64" ios_code_signing_identity="E37AE8646D7CFE04723F31BEFC03E89918C847D0"'
# 编译真机测试Demo
ninja -C out/ios_64 AppRTCMobile
# 配置总工程
gn gen out/ios --args='target_os="ios" target_cpu="arm64" ios_code_signing_identity="E37AE8646D7CFE04723F31BEFC03E89918C847D0"' --ide=xcode
open -a Xcode.app out/ios/all.xcworkspace
复制代码