Build iOS AppRTC iOS AppRTC Deep Dive (Pt. 1)
2015-10-20 16:24
465 查看
iOS AppRTC Deep Dive (Pt. 1)
At Pristine, we use WebRTC in our EyeSight mobile applications. Our target markets are healthcare physicians and hospitals, meaning we have to comply with HIPAA.Research shows that iOS is used by 68% of healthcare physicians [May 2013] in
the United States, so HIPAA compliance (by way of WebRTC support) on iOS is mission critical.
Understanding the Build Process
The iOS build process is nearly identical to the Android build process, with a few slight changes.1. Set
the
target_os=['mac']initially, then re-sync with
target_os=['ios', 'mac']
-
WEBRTC_DEBUG=trueis set by default
2. Incorporate static libraries instead of shared objects (Apple requires static libraries)
- Copy the libWebRTC-LATEST-Universal-Debug.a & public *.h files into your xcode project
3. Automatically generate a fat *.a library for ARMv7 & x86 (ia32) in
webrtc/libWebRTC-LATEST-Universal-Debug.a
4. The headers needed are referenced in
webrtc/headersafter a build
Obtaining the scripts
Clone/Pull from our Build Scripts GitHub repo:git clone https://github.com/pristineio/webrtc-build-scripts.git
Shoutout to those who just need to pull instead of clone :) you know who you are
Executing build scripts via terminal
This has been tested on a Retina MacBook Pro Running OSX 10.9.3Set the
WEBRTC_DEBUG,
WEBRTC_RELEASE,
or
WEBRTC_PROFILEenvironment variable to
trueif
you want to build that type.
Source the iOS build scripts by pasting this into the terminal.
# Add helper functions to your environment source ios/build.sh # Clone, make, compile (WebRTC) dance
That's it!
The build dance process takes quite a bit of time. First the, scripts will clone WebRTC (~2 GB of data), then will compile for Debug mode for the Simulator (ia32) and ios(ARMv7) devices (>4000 object files, millions of lines of code).
Executing build scripts via xcode
Open ios/WebRTC.xcodeproj in xcode or typeopen ios/WebRTC.xcodeprojin the terminal
Open the Schemes List:
Set the active scheme to WebRTC Dance: (32 or 64 bit, it is ignored)
Optionally to build for profile or release, edit the scheme and add the runtime environment variables for WebRTC Dance scheme
WEBRTC_RELEASEor
WEBRTC_PROFILEwith
the value set to
true
Build and run the current scheme (WebRTC Dance) by clicking the Play button
This will effectively run
source build.shand
dancein
an bash console printing to xCode
Monitoring the progress of the build:
Click on the Log Navigator
Click on the most recent WebRTC Dance Debug
If you see a spinning wheel on the right side next, that means it is still running.
This download will take about 2 GB of space on your system. YMMV on download times
Log messages similar to these means that the build process is downloading from Google Code
A trunk/webrtc/modules/audio_processing/aec/aec_resampler.c
A trunk/talk/p2p/base/p2ptransportchannel.h
Log messages similar to these mean that the build system is compiling
[440/2210] CC obj/third_party/icu/source/common/icuuc.cmemory.o
[906/2210] RULE Compile assembly source/libvpx/vp8/common/x86/loopfilter_sse2.asm
[2016/2210] CXX obj/webrtc/voice_engine/voice_engine.voe_network_impl.o
[2208/2210] LIBTOOL-STATIC libjingle_peerconnection_objc.a, POSTBUILDS
[2171/2210] OBJCXX obj/talk/app/webrtc/objc/libjingle_peerconnection_objc.RTCEnumConverter.o
Usually the compile process takes ≥10mins on an Intel Core i7 and ≥20 mins on an Intel Core i5
Near the end of a successful build, you will see a message on the console or logs about some simulator file not having symbols near the end of the script. A
Finished Dancing!message immediately follow.
Executing AppRTCDemo via Xcode
With WebRTC binary+headers already built and resolved, Xcode can now resolve the missing AppRTCDemoObjective-C code.
Open the Schemes List:
Hover over the AppRTCDemo Scheme:
Select any iPhone or iPad (real or simulator)
Build and run the AppRTCDemo scheme
Wait for build to finish (Should be quick, WebRTC is already precompiled)
AppRTCDemo should launch on either simulator or real ios device -- Success!
Developing like an iOS Developer
Including the RTCPeerconnection API in your own *.xcodeproj
Option 1 - Cocoapods (maintainable)
Note: There is a known bug because I hit the filesize limit on the bitbucket repo. I am working with the cocoapods team to move this to an HTTP source. Will update again soon.libjingle_peerconnection is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "libjingle_peerconnection" # Add this to the bottom so it won't have issues with active architecture post_install do |installer_representation| installer_representation.project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' config.build_settings['VALID_ARCHS'] = ['armv7', 'i386'] end end end
That's it!
I started the builds at r6798, so make sure you set the revision you want.
Also, the Cocoapods based AppRTCDemo can be found here.
Option 2 - Integrate into your own project (not as maintainable)
Take a look at the AppRTCDemo for extra tipsCopy all the files from the ~/webrtc/headers into your Xcode project. It is up to you if you want to copy into the project itself (Probably yes).
Copy the static library from webrtc/libWebRTC-LATEST-Universal-Debug.a into your xcode project. It is up to you if you want to copy into the project itself (again, probably yes).
Go to the target settings in Xcode, Build Phases
Under Link Binary With Libraries, make sure you have these on the list, Otherwise add them:
Foundation.framework
AVFoundation.framework
CoreGraphics.framework
CoreMedia.framework
GLKit.framework
libc.dylib
libsqlite3.dylib
libstdc++.6.0.9.dylib
libWebRTC-LATEST-Universal-Debug.a
UIKit.framework
At this point you should be able to make any WebRTC calls using the peer connection library. Simply
#importany
files you need from the WebRTC Objective-C public headers.
Happy Building!
P.S. We're pleased to announce our new Pristine baby, Bot the Builder! He's so cute, he builds, tests and merges in our code!
相关文章推荐
- [转载]Activity中ConfigChanges属性的用法
- jquery mobile实现拨打电话功能的几种方法
- jquery Mobile入门―多页面切换示例学习
- 让jQuery Mobile不显示讨厌loading界面的方法
- jquery mobile动态添加元素之后不能正确渲染解决方法说明
- ThinkPHP Mobile使用方法简明教程
- jquery mobile的触控点击事件会多次触发问题的解决方法
- 整合jQuery Mobile+AngularJs 经验谈
- 工作中遇到的问题
- Titanium UI之TableViews组件
- android 打开APN
- 自适应网页设计
- 微信公众平台开发 OAuth2.0网页授权认证
- 如何搭建Windows Phone 7开发环境
- 2. 接口的实现
- 3. 接口的继承
- 从运营商的视角来看移动健康服务的现状和未来发展
- PHP判断用户是否手机访问
- 构建一个Flex的Mobile APP
- js判断是否移动设备