【WebRTC】在IOS下编译WebRTC

项目上需要对webRTC进行一些research,就在网上下载了源码,并在IOS平台对其进行了编译。大致过程,以及期间碰到的问题如下:

【官网】

【步骤】

参照官网的步骤,要下载和编译源码,需要安装两个工具 depot_tools 和 git

1. 安装git

2.安装depot_tools

a 启动终端,当前路径为:/Users/xxx :

b git 命令获取depot_tools:git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

c 把depot_tools 设置到PATH中

vi ~/.bash_profile

export PATH="$PATH":`pwd`/depot_tools

按“ESC”,输入 ":wq!" 保存退出;

source ~/.bash_profile 使PATH设置生效

echo $PATH 查看设置是否生效。

3. 获取WebRTC 源码。

a 新建WebRTC文件夹,并在终端进入该文件夹

b 执行命令 :

gclient sync –force

gclient runhooks –force

4 编译源码

根据 trunk/talk/app/webrtc/objc/readme 说明,编译源码。

a 检查WebRTC目录下.gclient 文件的内容,是否包含 target_os = [‘ios’, ‘mac’] 如果没有,则添加,并保存。

【注】如果没有这一步,在步骤C会失败,出现error。

b 在.gclient下添加后,在终端WebRTC路径下,重新执行: gclient sync

C 根据readme,,进入trunk路径,执行如下命令

export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1" export GYP_GENERATORS="ninja"

【注】如果这里改成"xcode",则会产生相应的xcode工程文件。

https://groups.google.com/forum/#!topic/discuss-webrtc/VJg-fk2-i_0[1-25-false]

export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=ia32"

export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_sim" export GYP_CROSSCOMPILE=1

gclient runhooks

ninja -C out_sim/Debug iossim AppRTCDemo

d 在trunk/out_sim/Debug 路径下会产生一个文件 AppRTCDemo.app

Q: 怎么把这个app装到模拟器上??

执行命令即可启动demo

./out_sim/Debug/iossim out_sim/Debug/AppRTCDemo.app

********************编译产生.xcodeproj工程文件************************************

https://github.com/lukeweber/webrtc-jingle-client/blob/master webrtc-jingle-client

# mkdir webrtcjingleproject# cd webrtcjingleproject# gclient config https://github.com/lukeweber/webrtc-jingle-client.git –name trunk# gclient sync# Change your .gclient file in trunk/../.gclient# 添加target_os = [‘ios’]# 运行 gclient sync again# ./build/gyp_chromium –depth=. -DOS=ios -Dinclude_tests=0 -Denable_protobuf=0 -Denable_video=0 webrtcjingle.gyp则会在trunk下创建webrtcjingle.xcodeproj 打开即可。

学习会使你永远立于不败之地。

【WebRTC】在IOS下编译WebRTC

相关文章:

你感兴趣的文章:

标签云: