<返回更多

IOS技术分享|WebRTC iOS源码下载&编译

2021-11-10    anyRTC云平台
加入收藏

前言

最近对 WebRTC IOS 端源码进行了下载和编译,网上针对 WebRTC iOS 端的编译文章基本都是几年前的,有些地方已经不适用于最新版的 WebRTC 的编译,简单记录下载&编译的过程,以 M93 版本为例。

编译环境

硬件:macBook Pro (Retina, 15-inch, Mid 2015)

系统:macOS Big Sur 11.5

安装 depot_tools

  • depot_tools 是一套 google 用来编译 Chromium 或者 WebRTC 的构建工具,获取 depot_tools 源码前,需开启 VPN 服务。

```

$ mkdir webrtc

$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

```

如果出现如下错误,首先检查 VPN 是否连接成功,其次配置 macOS 终端代理

IOS技术分享|WebRTC iOS源码下载&编译

 

配置终端代理

在开启的 VPN 客户端偏好设置中配置信息如下:

IOS技术分享|WebRTC iOS源码下载&编译

 

注意:配置终端代理只对当前终端有用,重启后需要重新配置

```

$ export http_proxy=http://127.0.0.1:10887

$ export https_proxy=http://127.0.0.1:10887

$ export all_proxy=http://127.0.0.1:10887

```

IOS技术分享|WebRTC iOS源码下载&编译

 

配置环境变量

```

$ echo "export PATH=$PWD/depot_tools:$PATH" > $HOME/.bash_profile

$ source $HOME/.bash_profile

```

检查是否配置成功

```

$ echo $PATH

```

安装 ninja

ninja 是 WebRTC 的编译工具。

```

$ git clone git://github.com/martine/ninja.git

$ cd ninja/

$ ./bootstrap.py

```

复制到系统目录(也可配置坏境变量)

```

$ sudo cp ninja /usr/local/bin/

$ sudo chmod a+rx /usr/local/bin/ninja

```

下载 WebRTC 源码

设置要编译的平台到环境变量

```

$ export GYP_DEFINES="OS=ios"

```

下载源码

```

$ fetch --nohooks webrtc_ios

```

指定分支(以 M93版本为例)

```

$ gclient sync -r 25e3fd53a79bfdb2bd647ee3a199eb9c3a71d271

```

分支版本可以在[Release Notes](
https://github.com/webrtc/webrtc-org/blob/gh-pages/release-notes/index.md)中查找,目前最新的是M95版本。

IOS技术分享|WebRTC iOS源码下载&编译

 

编译 WebRTC 源码

iOS 版本我们可以使用源码中自带的编译脚本,目录如下,不同的 WebRTC 版本路径可能不一样,脚本可根据需求自行配置。

IOS技术分享|WebRTC iOS源码下载&编译

 

```

$ cd /Users/a1/Desktop/webrtc/src

$ /Users/a1/Desktop/webrtc/src/tools_webrtc/ios/build_ios_libs.py

```

编译完成后可在 src/out_ios_libs 目录下找到WebRTC.framework

生成 Example 并运行

```

$ gn gen out/ios --args='target_os="ios" target_cpu="arm64" is_component_build=false ios_enable_code_signing=false' --ide=xcode

```

下载&编译操作源码

```

Last login: Tue Sep 14 12:49:30 on ttys001

The default interactive shell is now zsh.

To update your account to use zsh, please run `chsh -s /bin/zsh`.

For more details, please visit https://support.Apple.com/kb/HT208050.

yushengzhudeMacBook-Pro:~ a1$ cd /Users/a1/Desktop/webrtc

$ ls

depot_tools

$ export PATH=$PATH:"/Users/a1/Desktop/webrtc/depot_tools"

$ export http_proxy=http://127.0.0.1:10887

$ export https_proxy=http://127.0.0.1:10887

$ export all_proxy=http://127.0.0.1:10887

$ export GYP_DEFINES="OS=ios"

$ fetch --nohooks webrtc_ios

Running: gclient root

WARNING: Your metrics.cfg file was invalid or nonexistent. A new one will be created.

Running: gclient config --spec 'solutions = [

{

"name": "src",

"url": "https://webrtc.googlesource.com/src.git",

"deps_file": "DEPS",

"managed": False,

"custom_deps": {},

},

]

target_os = ["ios"]

'

Running: gclient sync --nohooks --with_branch_heads

________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://webrtc.googlesource.com/src.git /Users/a1/Desktop/webrtc/_gclient_src_mgr39v0v' in '/Users/a1/Desktop/webrtc'

Cloning into '/Users/a1/Desktop/webrtc/_gclient_src_mgr39v0v'...

remote: Sending approximately 332.17 MiB ...

remote: Counting objects: 75, done

remote: Finding sources: 100% (75/75)

remote: Total 388264 (delta 284781), reused 388243 (delta 284781)

Receiving objects: 100% (388264/388264), 332.12 MiB | 5.96 MiB/s, done.

Resolving deltas: 100% (284781/284781), done.

[0:01:50] Still working on:

[0:01:50] src

1>Syncing projects: 0% ( 0/ 2)

[0:01:55] Still working on:

[0:01:55] src

Syncing projects: 26% (11/42) src/ios

[0:04:39] Still working on:

[0:04:39] src/third_party

[0:04:39] src/tools

[0:08:52] Still working on:

[0:08:52] src/third_party

[0:08:52] src/tools

Syncing projects: 38% (16/42) src/tools/luci-go:infra/tools/luci/swarming/${pla

[0:09:52] Still working on:

[0:09:52] src/third_party

...

[0:24:17] Still working on:

[0:24:17] src/third_party

Syncing projects: 100% (42/42), done.

Running: git submodule foreach 'git config -f $toplevel/.git/config submodule.$name.ignore all'

Running: git config --add remote.origin.fetch '+refs/tags/*:refs/tags/*'

Running: git config diff.ignoreSubmodules all

$ gclient sync

Syncing projects: 100% (42/42), done.

Running hooks: 41% (10/24) mac_toolchain

________ running 'vPython/ target=_blank class=infotextkey>Python src/build/mac_toolchain.py' in '/Users/a1/Desktop/webrtc'

Skipping Mac toolchain installation for mac

Running hooks: 45% (11/24) clang

________ running 'vpython src/tools/clang/scripts/update.py' in '/Users/a1/Desktop/webrtc'

Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-14-init-2175-g945cde8b-1.tgz .......... Done.

Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-14-init-2175-g945cde8b-1.tgz .......... Done.

Hook 'vpython src/tools/clang/scripts/update.py' took 30.90 secs

Running hooks: 58% (14/24) clang_format_mac

________ running 'download_from_google_storage --no_resume --platform=darwin --no_auth --bucket chromium-clang-format -s src/buildtools/mac/clang-format.sha1' in '/Users/a1/Desktop/webrtc'

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environmentvariable from being used.

To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

0> Downloading src/buildtools/mac/clang-format@5ba974b3b37f9f4e3b44fdde11d7ef2ab71619ab...

Downloading 1 files took 25.228423 second(s)

Hook 'download_from_google_storage --no_resume --platform=darwin --no_auth --bucket chromium-clang-format -s src/buildtools/mac/clang-format.sha1' took 25.33 secs

Running hooks: 79% (19/24) test_fonts

________ running 'download_from_google_storage --no_resume --extract --no_auth --bucket chromium-fonts -s src/third_party/test_fonts/test_fonts.tar.gz.sha1' in '/Users/a1/Desktop/webrtc'

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environmentvariable from being used.

To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

0> Downloading src/third_party/test_fonts/test_fonts.tar.gz@cd96fc55dc243f6c6f4cb63ad117cad6cd48dceb...

0> Extracting 33 entries from src/third_party/test_fonts/test_fonts.tar.gz to src/third_party/test_fonts/test_fonts

Downloading 1 files took 25.751998 second(s)

Hook 'download_from_google_storage --no_resume --extract --no_auth --bucket chromium-fonts -s src/third_party/test_fonts/test_fonts.tar.gz.sha1' took 25.84 secs

Running hooks: 91% (22/24)

________ running 'download_from_google_storage --directory --recursive --num_threads=10 --no_auth --quiet --bucket chromium-webrtc-resources src/resources' in '/Users/a1/Desktop/webrtc'

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environmentvariable from being used.

To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

Hook 'download_from_google_storage --directory --recursive --num_threads=10 --no_auth --quiet --bucket chromium-webrtc-resources src/resources' took 1268.21 secs

Hook 'vpython src/testing/generate_location_tags.py --out src/testing/location_tags.json' took 34.77 secs

Running hooks: 100% (24/24), done.

$ gclient sync -r 25e3fd53a79bfdb2bd647ee3a199eb9c3a71d271

Syncing projects: 100% (43/43), done.

Running hooks: 41% (10/24) mac_toolchain

________ running 'vpython src/build/mac_toolchain.py' in '/Users/a1/Desktop/webrtc'

Skipping Mac toolchain installation for mac

Running hooks: 45% (11/24) clang

________ running 'vpython src/tools/clang/scripts/update.py' in '/Users/a1/Desktop/webrtc'

Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-13-init-14732-g8a7b5ebf-2.tgz .......... Done.

Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-13-init-14732-g8a7b5ebf-2.tgz .......... Done.

Hook 'vpython src/tools/clang/scripts/update.py' took 31.97 secs

Running hooks: 58% (14/24) clang_format_mac

________ running 'download_from_google_storage --no_resume --platform=darwin --no_auth --bucket chromium-clang-format -s src/buildtools/mac/clang-format.sha1' in '/Users/a1/Desktop/webrtc'

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environmentvariable from being used.

To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

Running hooks: 79% (19/24) test_fonts

________ running 'download_from_google_storage --no_resume --extract --no_auth --bucket chromium-fonts -s src/third_party/test_fonts/test_fonts.tar.gz.sha1' in '/Users/a1/Desktop/webrtc'

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environmentvariable from being used.

To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

Running hooks: 91% (22/24)

________ running 'download_from_google_storage --directory --recursive --num_threads=10 --no_auth --quiet --bucket chromium-webrtc-resources src/resources' in '/Users/a1/Desktop/webrtc'

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environmentvariable from being used.

To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

Hook 'vpython src/testing/generate_location_tags.py --out src/testing/location_tags.json' took 35.13 secs

Running hooks: 100% (24/24), done.

```

IOS技术分享|WebRTC iOS源码下载&编译

 

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>