Build iOS AppRTC iOS AppRTC Deep Dive (Pt. 1)

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=true is 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/headers after 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.3

  1. Set the WEBRTC_DEBUGWEBRTC_RELEASE, or WEBRTC_PROFILE environment variable to true if you want to build that type.
  2. 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

  1. Open ios/WebRTC.xcodeproj in xcode or type open ios/WebRTC.xcodeprojin the terminal
  2. Open the Schemes List:
  3. Set the active scheme to WebRTC Dance: (32 or 64 bit, it is ignored)
  4. Optionally to build for profile or release, edit the scheme and add the runtime environment variables for WebRTC Dance scheme WEBRTC_RELEASEor WEBRTC_PROFILE with the value set to true
  5. Build and run the current scheme (WebRTC Dance) by clicking the Play button

    This will effectively run source build.sh and dance in an bash console printing to xCode
  6. 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 AppRTCDemo Objective-C code.

  1. Open the Schemes List: 
  2. Hover over the AppRTCDemo Scheme:
  3. Select any iPhone or iPad (real or simulator)
  4. Build and run the AppRTCDemo scheme
  5. Wait for build to finish (Should be quick, WebRTC is already precompiled)
  6. 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 tips

  1. Copy 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).

  2. 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).

  3. Go to the target settings in Xcode, Build Phases

  4. 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 
  5. At this point you should be able to make any WebRTC calls using the peer connection library. Simply #import any 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! 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值