本文描述的是macOS下编译webRTC frmework的过程及编译过程中遇到的问题 并提供解决方案
步骤安装depot_tools 配置环境变量
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git export PATH $PATH:/Users/suntongmian/documents/develop/webrtc/depot_tools
下载WebRTC源码
#cd 到希望放置源代码的目录 执行以下命令 fetch --nohooks webrtc_ios #执行完毕上面命令后 gclient sync
编译WebRTC
gn gen out/ios --args target_os ios target_cpu arm64 is_debug true ninja -C out/ios framework_objc gn gen out/ios --args target_os ios target_cpu arm64 is_debug true python tools_webrtc/ios/build_ios_libs.py --bitcode #执行完毕后可以在src/out/ios目录中看到生成的项目工程问题记录 1. Exception: No 10.12 SDK found
Traceback (most recent call last):
File “/Users/zhouyongchao/documents/WorkingSpaces/webrtc_build/webrtc/src/build/mac/find_sdk.py”, line 127, in
print(main())
File “/Users/zhouyongchao/documents/WorkingSpaces/webrtc_build/webrtc/src/build/mac/find_sdk.py”, line 96, in main
raise Exception(‘No %s SDK found’ % min_sdk_version)
Exception: No 10.12 SDK found
解决方案:
通过命令xcrun --show-sdk-version可以知道当前SDK的版本修改.gn文件的mac_sdk_min选项为当前系统版本 如 11.0打开find_sdk.py阅读代码发现了只支持10.xx的系统 修改11即可 2. LASTCHANGE.committimeTraceback (most recent call last):
File “/Users/zhouyongchao/documents/WorkingSpaces/webrtc_build/webrtc/src/build/compute_build_timestamp.py”, line 127, in
sys.exit(main())
File “/Users/zhouyongchao/documents/WorkingSpaces/webrtc_build/webrtc/src/build/compute_build_timestamp.py”, line 113, in main
last_commit_timestamp int(open(lastchange_file).read())
IOError: [Errno 2] No such file or directory: ‘/Users/zhouyongchao/documents/WorkingSpaces/webrtc_build/webrtc/src/build/util/LASTCHANGE.committime’
解决方案
在src目录执行./build/util/lastchange.py build/util/LASTCHANGE
3. gn gen out/ios --args target_os “ios” target_cpu “arm64” is_debug true’报错Automatic code signing identity selection was enabled but could
not find exactly one code signing identity matching
iPhone Developer. Check that your keychain
is accessible and that there is a valid code signing identity
listed by xcrun security find-identity -v -p codesigning
TIP: Simulator builds don’t require code signing…
解决方案
打开src/build/config/ios/ios_sdk.gni文件 把ios_code_signing_identity_description iPhone Develoer 修改为ios_code_signing_identity_description Apple Development 如果方法1不生效 可以尝试把命令更改为gn gen out/ios --args target_os ios target_cpu arm64 is_component_build false ios_enable_code_signing false --ide xcode 编译APP报错/bin/sh: …/…/third_party/llvm-build/Release Asserts/bin/clang : No such file or directory
解决方案 手动到官网https://commondatastorage.googleapis.com/chromium-browser-clang/index.html下载clang 放到相应的文件夹(src/third_party/llvm-build/Release Asserts)下面 注意clang 和macOS的版本对应问题
代码报错 set but not used [-Werror,-Wunused-but-set-variable]variable ‘zeroGainLvl’ set but not used [-Werror,-Wunused-but-set-variable]
原因 这只是警告 只是clang 编译器将警告当作了错误输出
解决方案
进入build/config/compile/BUILD.gn文件中 将treat_warnings_as_errors置为false



