webrtc (2) iOS平台编译过程

本文详细介绍了在iOS平台上编译WebRTC的过程,包括按照官方指南操作、使用ninja命令编译AppRTCDemo应用、解决编译过程中可能出现的多重证书问题以及处理clang执行错误。编译成功后,通过在apprtc.appspot.com获取room,可以在iOS和网页端进行呼叫测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编译和运行

如果前面下载的文件是完整的,编译其实是比较顺利的。


 http://www.webrtc.org/native-code/ios

按照指导一步步完成即可编译成功。


首先

export GYP_CROSSCOMPILE=1
export GYP_DEFINES="OS=ios target_arch=arm arm_version=7"
export GYP_GENERATOR_FLAGS="output_dir=out_ios"
export GYP_GENERATORS=ninja


然后执行

webrtc/build/gyp_webrtc

然后执行:

ninja -C out_ios/Debug-iphoneos AppRTCDemo

编译完成后会生成AppRTCDemo.app


然后执行下列命令生成一个Xcode工程:

export GYP_GENERATOR_FLAGS="xcode_project_version=3.2 xcode_ninja_target_pattern=All_iOS xcode_ninja_executable_target_pattern=AppRTCDemo|libjingle_peerconnection_unittest|libjingle_peerconnection_objc_test output_dir=out_ios"

export GYP_GENERATORS="ninja,xcode-ninja"


webrtc/build/gyp_webrtc


然后在src目录下会生成一个all.ninja.xcworkspace,打开此工程即可按照正常的Xcode方式运行demo。


demo运行之后,需要一个room , room在https://apprtc.appspot.com/上获取,网页端和iOS端都进入之后,呼叫就会建立成功。

如果呼叫不成功,同样需要你的网页端和客户端都需要连接vpn。


常见错误:多重证书


如果遇到多重证书的问题,AssertionError: Multiple codesigning fingerprints for identity: iPhone Developer 

可参考 http://ninjanetic.com/how-to-get-started-with-webrtc-and-ios-without-wasting-10-hours-of-your-life/ 

大概步骤:

1, 用 security find-identity 找到你想要的identify

2,在 src/chromium/src/build/common.gypi 里有一个CODE_SIGN_IDENTITY,

把里面的  'CODE_SIGN_IDENTITY[sdk=iphoneos*]': 'iPhone Developer' 修改一下,
比如修改成  'CODE_SIGN_IDENTITY[sdk=iphoneos*]': 'iPhone Developer: Taylor Wei (DUABQZJ9JG)'

3,重新执行 

webrtc/build/gyp_webrtc

ninja -C out_ios/Debug-iphoneos AppRTCDemo

不常见错误:编译器错误

如果遇到:/bin/sh: ../../third_party/llvm-build/Release+Asserts/bin/clang: cannot execute binary file

这个多半是因为下载了错误的文件,比如在Linux环境下载iOS代码,然后拷贝到Mac机上编译。

可通过如下过程定位:

1,找到clang目录。执行 whereis clang

2,查看clang的目标架构。

执行 file clang_path(clang_path是第一步中找到的),在mac上的执行结果应当是

/usr/bin/clang: Mach-O 64-bit executable x86_64

3,查看third_party/llvm-build/Release+Asserts/bin/clang的目标架构,如果是如下的结果说明是Linux环境:

clang: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, stripped


此时你需要重新下载正确的llvm-build目录,并替换到src/chromium/src/third_party/llvm-build



评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值