[!] 请将所有与 WebRTC 相关的(非特定于此二进制构建)错误和问题报告给论坛或官方错误追踪器。您很可能在那里获得专业的帮助。
[!] 上游支持位代码,但 Google 源代码构建器(GN)生成带位代码的 ~700Mb 二进制文件,因此很难通过 CocoaPods/Carthage 作为框架分发,这就是为什么在我的构建中位代码是 禁用 的。查看相应问题:https://bugs.chromium.org/p/webrtc/issues/detail?id=5085
确保为您的项目禁用位代码:转到您项目的设置并找到 构建设置 选项卡,选择 所有 并搜索 位代码,然后将其设置为 无。
如果遇到链接器错误,请尝试将框架添加到内嵌二进制部分。
CocoaPods(添加到 Podfile)
pod "WebRTC"
Carthage(添加到 Cartfile)
github "Anakros/WebRTC"
手动:只需从最新发布版下载框架并将其复制到您的项目中
您只能使用二进制发布版,因为整个 WebRTC 仓库需要 ~12Gb 的磁盘空间
import WebRTC
let device = UIDevice.string(for: UIDevice.deviceType())
print(device)
print(RTCInitializeSSL())
@import WebRTC;
NSString *device = [UIDevice stringForDeviceType:[UIDevice deviceType]];
NSLog(@"%@", device);
NSLog(@"%d", RTCInitializeSSL());
查看官方示例应用程序!
使用 https://chromium.googlesource.com/external/webrtc/
并使用 tools_webrtc/ios/build_ios_libs.py
脚本构建,以下修改(以启用 x86 架构):
diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py
index 734f3e216..e6f250c97 100755
--- a/tools_webrtc/ios/build_ios_libs.py
+++ b/tools_webrtc/ios/build_ios_libs.py
@@ -165,8 +165,6 @@ def main():
# 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')
# Build all architectures.
for arch in architectures: