webrtc (2) iOS平台编译过程

编译和运行

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


 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



猜你喜欢

转载自blog.csdn.net/wangruihit/article/details/45366571