一:安装brew和git
1. mkdir /usr/local
2. curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
3. /usr/local/bin/brew install git
二:下载编译webrtc
1. 下载depot_tools
LeeHonGee-MacBook:~ mac$ svn co http://src.chromium.org/svn/trunk/tools/depot_tools
2. 打开source .bash_profile 添加depot_tools路径到系统目录
export PATH=$PATH:/Users/mac/depot_tools
3. LeeHonGee-MacBook:~ mac$ vi ~/.bash_profile
export PATH=XXX/depot_tools:"$PATH"
按“ESC”,输入 ":wq!" 保存退出;
source ~/.bash_profile 使PATH设置生效
echo $PATH 查看设置是否生效。
4. 首次下载输入下载命令:
fetch webrtc_ios
等待几个 G 下载完成,最好没报错。 报错说明网络或上边代理设置存在问题,排除问题然后执行如下命令: 下载代码:
git pull 或 git fetch
下载依赖项生成编译文件:
gclient sync
5. 链接
cd src
5. 配置环境变量
5.1 ninja编译方式
配置环境变量(webrtc_ios\ios\webrtc\src目录下)
export GYP_CROSSCOMPILE=1
export GYP_GENERATORS=ninja
(1)arm(真机)
export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=arm"
export GYP_GENERATOR_FLAGS="output_dir=out_ios_armeabi_v7a"
(2)arm64(真机)
export GYP_DEFINES="OS=ios target_arch=arm64"
export GYP_GENERATOR_FLAGS="output_dir=out_ios_arm64_v8a"
(3)ia32(模拟器)
export GYP_DEFINES="OS=ios target_arch=ia32"
export GYP_GENERATOR_FLAGS="output_dir=out_ios_x86"
(4)x64(模拟器)
export GYP_DEFINES="OS=ios target_arch=x64"
export GYP_GENERATOR_FLAGS="output_dir=out_ios_x86_64"
(5))x64(mac)
export GYP_DEFINES="OS=mac target_arch=x64"
export GYP_GENERATOR_FLAGS="output_dir=out_mac_x86_64"
5.2 xcode 编译方式
配置环境变量(webrtc_ios\ios\webrtc\src目录下)
export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1"
export GYP_GENERATORS="xcode"
(1)arm(真机)
export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=arm"
(2)arm64(真机)
export GYP_DEFINES="OS=ios target_arch=arm64"
(3)ia32(模拟器)
export GYP_DEFINES="OS=ios target_arch=ia32"
(4)x64(模拟器)
export GYP_DEFINES="OS=ios target_arch=x64"
(5))x64(mac)
export GYP_DEFINES="OS=mac target_arch=x64"
6 编译
Note that you can set output_dir to whatever you'd like. It will be created under src/
(1)gyp构建编译文件
webrtc/build/gyp_webrtc
(2)编译
一、ninja
Now to compile, just run ninja on the appropriate target. E.g.
ninja -C out_ios_armeabi_v7a/Debug-iphoneos
二、Xocde
点击运行按钮
7. 合成库
libtool -static -v -o libWebRTC_armv7.a *.a