WEBRTC iOS Framework Compilation

Source: Internet
Author: User

Selection of iOS framework for 1.WebRTC

Currently two more active open source WEBRTC implementations.

    • Google WebRTC:

Project address is: https://code.google.com/p/webrtc/

    • Ericsson OPENWEBRTC:

Project address is: HTTPS://GITHUB.COM/ERICSSONRESEARCH/OPENWEBRTC

Our Camp David Education is designed to build the iOS app development framework by using WEBRTC Video Call technology in the field of practical projects for students, choosing Google's WEBRTC project. This is because the WEBRTC support for both Chrome and Firefox browsers is currently in use. So the problem is, since the browser is supported by WEBRTC, then we will go to the porting to build it to the iOS platform, why not directly with WebView? Yes, not yet! Apple has been a serious drag on this. But he has his cool FaceTime technology, can be anywhere in the video call, but he does not open source, so we can only covet. So it's an honest transplant webrtc. Fortunately, Google's chromium project developers have implemented a set of APIs for their WEBRTC objective-c.

However, ugly words still said that in front of the good, to start from the zero integration of WEBRTC into our app, is simply a nightmare, because the WEBRTC project and Chromium project has a certain association of dependencies, and these projects are cross-platform large projects, using Google's own set of compiled system, It's much more complicated than our daily Ides. If we need to get a WEBRTC library or framework, we need to forget about the Xcode IDE and interface Builder, and we're going to switch to the end-of-the-line technology to conquer it.

2. Start WEBRTC source Download

Prerequisites:

    • I am now using macbook,8g memory, running OS X 10.9.5.
    • Install the latest git and subversions and make sure it works correctly.
    • Xcode 6.1.1 and Command line Tools.
    • Chinese mainland users additional requirements, fast VPN, or fast shadowsocks service. (FQ and set up proxies for Git and SVN as well as curl).
2.1 Creating a compiled directory

We create a directory dedicated to the project compile tool and Project code repository. Make sure that the directory contains at least 8~10g of available disk space. Open the system's terminal tool into the shell:

wuqiong:~ apple$mkdir -p $HOME/opensource/webrtc_build/
2.2 Download Chromium's Depot tool

Before you execute the command below, make sure that you are already connected to the fast VPN already FQ, or that you have configured a valid SOCKSFQ agent for git individually, and if that's not the problem, don't say it.

wuqiong:~ apple$cd $HOME/opensource/webrtc_build/wuqiong:webrtc_build apple$git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

This is a set of build tools that Google uses to compile chromium or WEBRTC, and it will be used in our subsequent compilation. For the command line to be easy to use, we add the path of these tools to the system environment variable path:

wuqiong:webrtc_build apple$echo "export PATH=$PWD/depot_tools:$PATH" > $HOME/.bash_profile

You then need to close the current terminal to reopen one of the environment variables that are set above to take effect. Or at the moment the terminal executes the get started command in the current terminal in Riga to take effect:

wuqiong:webrtc_build apple$source $HOME/.bash_profile
2.3 Download WebRTC's source code

Create a WEBTRTC subdirectory under our compiled working directory Webrtc_build to hold the code, execute the following command:

wuqiong:webrtc_build apple$ mkdir webrtcwuqiong:webrtc_build apple$ cd webrtc 

After the above inspection work is right, we need to start to download a copy of the WEBRTC Project's code repository locally. Because of its large warehouse, about a total need to download 6g+ things. So this step needs to be patient. And there needs to be a stable, accessible Internet. Execute the following command, then:

wuqiong:webrtc apple$ gclient config --name src http://webrtc.googlecode.com/svn/trunkwuqiong:webrtc apple$ echo "target_os = [‘ios‘]" >> .gclientwuqiong:webrtc apple$ gclient sync --force

Fq quickly go to drink coffee, slowly go to ask sister. Come back after it's done. If all the above commands are going well, we can go down and start compiling. (for the convenience of everyone, I have packaged a backup of the Webrtc_build directory so that you can save a lot of code download time.) The package file has 5G, is looking for the network disk storage, and then announced.)

2.4 Compiling Webrtc.framework

In this step, the source code should have been downloaded. These sources can be compiled into several platforms, OS X, Linux, Windows, Android, iOS, etc. here we just need to compile the iOS platform WEBRTC, and make it into a development framework for iOS. We can't use the Xcode tool here, because these projects don't support Xcode at all. We need to get this done in the terminal command line environment!

First of all, in order for us to play black weapons, we need to create a script under the WEBRTC Project code directory, which is a one-click Framework compilation script that I specifically wrote to simplify the complexity of the command and improve the usability of this script, which is the core of today's black technology. Create an empty file first, Then give execute permission:

wuqiong:webrtc apple$ touch build_webrtc.shwuqiong:webrtc apple$ chmod +x build_webrtc.sh

Then use the editor to open the script file you just created, paste in the following script and then save and close:

#!/bin/bash# Script to build webrtc.framework for IOS# Copyright (C) 2015 Camp David Education-All rights Reserved# last revised 28/1/2015#function Build_iossim_ia32(){Echo"* * * * building WebRTC for the ia32 IOS simulator";ExportGyp_generators="Ninja";ExportGyp_defines="Build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1 os=ios target_arch=ia32";ExportGyp_generator_flags="$GYP _generator_flags output_dir=out_ios_ia32";ExportGyp_crosscompile=1;pushd SRC; Gclient Runhooks; Ninja-c Out_ios_ia32/release-iphonesimulator Iossim Apprtcdemo;Echo"* * * creating IOS IA32 Libraries";pushd out_ios_ia32/release-iphonesimulator/; Rm-f LIBAPPRTC_SIGNALING.A;popd; Mkdir-p Out_ios_ia32/libs; Libtool-static-o out_ios_ia32/libs/libwebrtc-ia32.a out_ios_ia32/release-iphonesimulator/lib*.a; Strip-s-x-o out_ios_ia32/libs/libwebrtc.a-r out_ios_ia32/libs/libwebrtc-ia32.a; Rm-f out_ios_ia32/libs/libwebrtc-ia32.a;Echo"* * * Result: $PWD/out_ios_ia32/libs/libwebrtc.a";popd;}function build_iossim_x86_64(){Echo"* * * * building WebRTC for the x86_64 IOS simulator";ExportGyp_generators="Ninja";ExportGyp_defines="Build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1 os=ios target_arch=x64 target_subarch=arm64";ExportGyp_generator_flags="$GYP _generator_flags output_dir=out_ios_x86_64";ExportGyp_crosscompile=1;pushd SRC; Gclient Runhooks; Ninja-c Out_ios_x86_64/release-iphonesimulator Iossim Apprtcdemo;Echo"* * * creating IOS x86_64 Libraries";pushd out_ios_x86_64/release-iphonesimulator/; Rm-f LIBAPPRTC_SIGNALING.A;popd; Mkdir-p Out_ios_x86_64/libs; Libtool-static-o out_ios_x86_64/libs/libwebrtc-x86_64.a out_ios_x86_64/release-iphonesimulator/lib*.a; Strip-s-x-o out_ios_x86_64/libs/libwebrtc.a-r out_ios_x86_64/libs/libwebrtc-x86_64.a;Echo"* * * Result: $PWD/out_ios_x86_64/libs/libwebrtc.a";popd;}function build_iosdevice_armv7(){Echo"* * * * building WebRTC for armv7 IOS devices";ExportGyp_generators="Ninja";ExportGyp_defines="Build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1 os=ios target_arch=armv7";ExportGyp_generator_flags="$GYP _generator_flags output_dir=out_ios_armv7";ExportGyp_crosscompile=1;pushd SRC; Gclient Runhooks; Ninja-c Out_ios_armv7/release-iphoneos Apprtcdemo;Echo"* * * creating IOS ARMV7 Libraries";pushd out_ios_armv7/release-iphoneos/; Rm-f LIBAPPRTC_SIGNALING.A;popd; Mkdir-p Out_ios_armv7/libs; Libtool-static-o out_ios_armv7/libs/libwebrtc-armv7.a out_ios_armv7/release-iphoneos/lib*.a; Strip-s-x-o out_ios_armv7/libs/libwebrtc.a-r out_ios_armv7/libs/libwebrtc-armv7.a;Echo"* * * Result: $PWD/out_ios_armv7/libs/libwebrtc.a";popd;}function build_iosdevice_arm64(){Echo"* * * * building WebRTC for arm64 IOS devices";ExportGyp_generators="Ninja";ExportGyp_defines="Build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1 os=ios target_arch=arm64 target_subarch=arm64";ExportGyp_generator_flags="$GYP _generator_flags output_dir=out_ios_arm64";ExportGyp_crosscompile=1;pushd SRC; Gclient Runhooks; Ninja-c Out_ios_arm64/release-iphoneos Apprtcdemo;Echo"* * * creating IOS arm64 Libraries";pushd out_ios_arm64/release-iphoneos/; Rm-f LIBAPPRTC_SIGNALING.A;popd; Mkdir-p Out_ios_arm64/libs; Libtool-static-o out_ios_arm64/libs/libwebrtc-arm64.a out_ios_arm64/release-iphoneos/lib*.a; Strip-s-x-o out_ios_arm64/libs/libwebrtc.a-r out_ios_arm64/libs/libwebrtc-arm64.a;Echo"* * * Result: $PWD/out_ios_arm64/libs/libwebrtc.a";popd;}function Combine_libs(){Echo"* * * * Combining Libraries"; Lipo-create SRC/OUT_IOS_IA32/LIBS/LIBWEBRTC.ASrc/out_ios_x86_64/libs/libwebrtc.aSrc/out_ios_armv7/libs/libwebrtc.aSrc/out_ios_arm64/libs/libwebrtc.a-output LIBWEBRTC.A;Echo"The public headers is located in $PWD/src/talk/app/webrtc/objc/public/*.h";}function create_framework(){Echo"* * * * Creating Webrtc.framework"; RM-RF Webrtc.framework; Mkdir-p webrtc.framework/versions/a/headers; CP./src/talk/app/webrtc/objc/public/*.h Webrtc.framework/versions/a/headers; CP LIBWEBRTC.A WEBRTC.FRAMEWORK/VERSIONS/A/WEBRTC;pushd webrtc.framework/versions; LN-SFH A Current;popd;pushd webrtc.framework; LN-SFH versions/current/headers Headers; LN-SFH VERSIONS/CURRENT/WEBRTC WebRTC;popd;}function clean(){Echo"* * * * cleaning";pushd SRC; RM-RF out_ios_arm64 out_ios_armv7 out_ios_ia32 out_ios_x86_64;popd;Echo"* * * * cleaned";}function update(){gclient Sync--forcepushd src SVN info| grep Revision >. /svn_rev.txtpopd}function Build_all(){Build_iossim_ia32&& build_iossim_x86_64&&Build_iosdevice_armv7&& build_iosdevice_arm64&&Combine_libs&& Create_framework;}function Run_simulator_ia32(){Echo"* * * * running WEBRTC appdemo on ia32 iOS simulator"; Src/out_ios_ia32/release-iphonesimulator/iossim Src/out_ios_ia32/release-iphonesimulator/apprtcdemo.app;}function run_simulator_x86_64(){Echo"* * * * running WEBRTC appdemo on x86_64 iOS simulator"; Src/out_ios_x86_64/release-iphonesimulator/iossim-d' IPhone 6 '-s' 8.1 ' Src/out_ios_x86_64/release-iphonesimulator/apprtcdemo.app;}function run_on_device_armv7 () { echo  "* * Launching on ARMV7 iOS device"  Ideviceinstaller-i src/out _ios_armv7/release-iphoneos/apprtcdemo.appecho  "* * * Launch complete" ;} function run_on_device_arm64 () {echo  "* * * Launching on arm64 iOS device"  Ideviceinstaller-i src/out_ios_arm64/ Release-iphoneos/apprtcdemo.appecho  "* * * Launch complete" ;}  #运行命令行参数中第一个参数所指定的Shell函数 [email protected]       

In addition to compiling the WEBRTC project's own Apprtcdemo application, this compilation script can also compile webrtc.framework.

Execute the following command to compile all we need:

wuqiong:webrtc apple$ ./build_webrtc.sh build_all

When the above command is complete, the WEBRTC framework we need is in the current directory. You can ls view it by command:

wuqiong:webrtc apple$ ls WebRTC.framework build_webrtc.sh  libWebRTC.a      srcwuqiong:webrtc apple$ 

The first one WebRTC.framework is the framework we need! Here we have our compilation task done! Is that so simple? Isn't that super-trouble? Hehe, the end of the Assembly force. The tedious part has been encapsulated in the shell script. If you are interested, you can study this script.

2.5 Webrtc.framework's dependence.

If the project uses the framework, then the compilation requires the following libraries and frameworks to be added to the project's Build phases:

    • Libstdc++.6.dylib
    • Libsqlite3.dylib
    • Libc++.dylib
    • Libicucore.dylib
    • Security.framework
    • Cfnetwork.framework
    • Glkit.framework
    • Audiotoolbox.framework
    • Avfoundation.framework
    • Coreaudio.framework
    • Coremedia.framework
    • Corevideo.framework
    • Coregraphics.framework
    • Opengles.framework
    • Quartzcore.framework
Important Notes

At present, Google official code in the ARMV7 platform has VP8 video encoding StackOverflow problem, will directly lead to the program crashes, if you need to learn more and get patches, please contact Camp David Education.

This document is organized by the Changsha Camp David Education .

WEBRTC iOS Framework Compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.