6

I was successfully able to build WebRTC on MAC following these instructions: http://www.webrtc.org/reference/getting-started

Has anyone successfully built it on iOS? I understand that someone (arik) has successfully built it on iOS: https://groups.google.com/forum/#!msg/discuss-webrtc/VJg-fk2-i_0/dtG200DOzsgJ But the steps are not clear.

Can someone (who built on ios) summarize the steps so that it will be useful for everyone trying it in the future?

ssk
  • 9,045
  • 26
  • 96
  • 169
  • i'm just build audio modules for iOS, and this may help others. http://stackoverflow.com/questions/12786468/webrtc-in-iphone-gas-preprocessor-issues/16852244#16852244 – Bill Hoo Jun 03 '13 at 09:19
  • jzn,could you help me for this question? http://stackoverflow.com/questions/20719873/build-the-webrtc-code-on-mac-but-meet-a-errorsys-cdefs-h-file-not-found-is – user3125405 Dec 21 '13 at 14:28
  • Oh boy, it's gotten worse in 2020. Official support has been dropped for pre-compiled libs and most guides to WebRTC.org are dead links. – Darkwonder Feb 06 '20 at 22:05

5 Answers5

5

I wrote a detailed blog post with all of the instructions on how to build the WebRTC example iOS application, as well as how to run it on the iOS simulator or an actual iOS device. You can take a look here to read the details, it's a pretty lengthy process.

jzn
  • 656
  • 10
  • 17
  • 1
    hi your blog post is not rendering very well, is the text white on white? – dazhi Mar 17 '14 at 03:22
  • @dazhi Sometimes those Google fonts take a while to download, and depending on your browser it might appear as white text until it finishes. Just give it a few secs. – jzn Mar 17 '14 at 14:59
  • @jzn : could you update that post for iOS9 and Xcode 7 – Nitin Jul 14 '16 at 09:22
3

Yes, compiling for iOS was a very painful task... especially getting it work in Xcode.

Here's my attempt to get AppRTC Demo for ios

Clone/Pull: https://github.com/pristineio/webrtc-build-scripts

After getting the repo, then open the xcode project within the ios directory. Set the target to WebRTC Dance, then execute. At this point the scripts will update depot_tools and do all the dirty work (pull, modify, build) so that your target for AppRTCDemo will able to resolve the missing files and execute.

Once that completes, you can change the target to AppRTC Demo with a simulator or a real device, click run and it should execute. There's more detailed information in the guide linked in there and updates in the readme.

If you are wondering what gets ran under the hood, check out the build.sh file in the ios directory of the git repo. The dance function is what's actually getting executed for you when you select WebRTC Dance.

Its not really easy to describe the build process (way too much going on) but the build scripts repo should definitely point you in the right direction and help you get AppRTCDemo on ios 'just work'

There's also a google developers video posted here, where they try and break down the build process so you can build for ios (the youtube title is misleading).

Also, I just added cocoapods support for ios webrtc, add this 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

Not all the revisions are built, so check out the the cocoadocs for which revisions are available

thebehera
  • 117
  • 8
3

Well, it's been a long time to answer this post. But, I hope someone might get better intuition from it.


I have been dealing with webrtc compilation processes for iOS and Android platforms. This process is really simple if you follow each step efficiently. To compile the library for iOS, follow the below-given commands and make sure you're using the same(only-1) tab of Mac terminal for WebRTC Native Compilation Setup as follows:

  1. Prerequisites
  2. Link Xcode with Command line
  3. Setup depot_tools
  4. Fetch Code for Development
  5. Selection of Branch
  6. Compile Library (iOS Framework)

1. Prerequisites:

First of all, make sure of the following things that you have already installed, if not then use these commands to do that:

 - sudo add-apt-repository ppa:openjdk-r/ppa
 - sudo apt-get install openjdk-8-jdk
 - sudo apt-get install pkg-config
 - sudo apt-get update

Please also install python==2.7, if it's not already installed.


2. Link Xcode with Command line:

- sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

- sudo xcode-select --switch /Library/Developer/CommandLineTools

3. Setup the Depot_tools:

- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

- export PATH="$PATH:${HOME}/depot_tools"

After that, start the following steps one by one. Every step takes its own time based on the machine specs and internet speed, so make sure every step is completed without interruption.

4. Fetch Code:

- mkdir webrtc_ios

- cd webrtc_ios

- fetch --nohooks webrtc_ios

- gclient sync

5. Select Branch-head:

- cd src

- ./build/install-build-deps.sh

- git checkout origin/master

- git branch

6. To compile every time:

Make sure you are in the webrtc_ios/src/ directory, then simply run this command:

- ./tools_webrtc/ios/build_ios_libs.sh

It turns out that you will end up with the compilation and building of WebRtc Framework holding Webrtc Header Files. You can simply drag and drop this framework into your Xcode production environment or simply import it.

As you have set up your compilation environment, now every time you make changes into your native stack, you can simply run this command ./tools_webrtc/ios/build_ios_libs.sh to generate an updated framework.

If you end up with an issue regarding the compilation of webrtc framework. Please follow these steps. Make sure you're in this directory webrtc_ios/src/:

 - git checkout origin/master

 # To make sure you're using origin/master

 - git branch

 - gclient revert

 - gclient sync

 - ./tools_webrtc/ios/build_ios_libs.sh

And hopefully, you will have your issues sorted. I always recommend you guys that You can check out a branch that would be behind the origin/master and doesn't have all dependencies and modules over there which are necessary to build webrtc framework for iOS. So, Please always checkout to branch/head of webrtc native stack


Now, if you tried with these both procedures to build the WebRTC such as:

1- Using Bash Build Tools (./tools_webrtc/ios/build_ios_libs.sh)

2- Using Manual Compilation

Examples

$ # debug build for 64-bit iOS
$ gn gen out/ios_64 --args='target_os="ios" target_cpu="arm64"'

$ # debug build for simulator
$ gn gen out/ios_sim --args='target_os="ios" target_cpu="x64"'

2.1- Compiling (ninja -C out/Debug)

Both procedures will work.


Muhammad Usman Bashir
  • 1,441
  • 2
  • 14
  • 43
2

I have been working in this space for the past few months now - webrtc on iOS is not easy. To help this problem I have added a github repo with a working example of and iOS app using webrtc.

https://github.com/gandg/webrtc-ios

The site references the google code site as well, so it should be a helpful starting point.

gp-coder
  • 1,050
  • 11
  • 14
  • Sorry but the doc is very poor, can't even know how to use it! – Marwen Trabelsi Jul 11 '14 at 15:04
  • this is not great. the prebuild libraries are for the simulator and there is little indication how to use it for anything else... – jheriko Aug 18 '14 at 09:58
  • 1
    Not sure I am following these comments. The README file is three pages long with notes on how to build and execute. It explicitly states to not use the simulator but only build for the device. The pre-built libraries are for a device and not the simulator. webrtc is not easy, Google has lots of documentation, but it still takes and investment of time to study, try, learn and repeat. When it does work, it is very rewarding to see the direct peer to peer in action for sure! – gp-coder Aug 22 '14 at 17:45
  • 2
    @gp-coder I can build, I can run. The only problem is that it cannot connect to another peer opened in Chrome. There is a line in console showed (null) then the app stopped (not crashed). Is that because I'm running on iOS 8+? – SnowWolf Mar 26 '15 at 03:16
1

This seems to build some of the modules: https://code.google.com/p/webrtc/issues/detail?id=1421#makechanges

ssk
  • 9,045
  • 26
  • 96
  • 169