Tuesday, July 14, 2015

Building WebRTC framework for iOS


The prerequisite software included below two 

- Depot tools 
- Git SCM 

Downloaded the Depot tools from git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

Now set the path to the Depot tools like this export PATH=`pwd`/depot_tools:"$PATH" 

Thats all is required for WebRTC dependencies tool installation 

Now as a second step in the main installation step after the pre-requisite software installation, need to set the required OS to iOS. This can be done by export GYP_DEFINES="OS=ios" 

Now the source code can be fetched using the command fetch webrtc_ios

This will fetch a regular WebRTC checkout with the iOS-specific parts added. The same checkout can be used for both Mac and iOS development, depending on the OS we set in the GYP_DEFINES 

To compile the code below are to be done 

GYP is used to generate the build instructions for ninja from the relevant .gyp files. Ninja is used to compile the source using the previously generated instructions. In order to configure GYP to generate the build files for iOS devices, certain environment variables to be set. 

export GYP_CROSSCOMPILE=1
export GYP_DEFINES=“OS=ios target_arch=arm”
export GYP_GENERATOR_FLAGS=“output_dir=out_ios”
export GYP_GENERATOR=ninja

This actually generated the configuration files for ninja. also can see that out_ios directory is created that contains various complile output folders debug release etc.  

Now it can be seen that the bundle id of the .app file is by default com.google.WebRTCDemo. 
To change this, we need to edit it manually and that can be done via changing the above to whatever required in /src/chromium/src/third_party/libjingle/source/talk/examples/objc/AppRTCDemo/ios/Info.plist 

Since the bundle id is changed, we need to also change the code signing identity. This can be changed in 

No to compile the code, we need to execute the command  ninja -C out_ios/Debug-iphoneos AppRTCDemo  

depending on which output directory is given in the GYP_GENERATOR_FLAGS, one need to give the path accordingly in the compile command. 

The build command generates the .app file. inorder to load that on to the device, just drag and drop on to the iTunes application. If the installation fails, it mostly due to the fact that the code signing is not correct. Below command can be used to repackage it 


 /usr/bin/xcrun -sdk iphoneos PackageApplication -v "AppRTCDemo.app" -o "/Users/muser.r/Desktop/per/KB/iOS/WebRTC/src/out_ios64/Release-iphoneos/AppRTCDemo.ipa" --sign "iPhone Distribution: company, Inc." --embed "/Users/muser.r/RR/Projects/certs/CCADist.mobileprovision"


References: 

No comments:

Post a Comment