Updating WebRTC Library in mobile (iOS) SDK: Dependency Management and Integration Challenges

876 views
Skip to first unread message

Kranti Bhange

unread,
Mar 8, 2024, 7:09:02 AM3/8/24
to discuss-webrtc
We have our own SDK code which is a bit old, developed in 2018. The structure inside our SDK code is as follows: a. CPP module: This module takes care of common features, one of which is conference calling feature. b. iOS and Android SDK modules: Written in their respective languages. (For iOS, webrtc_ios_79 is used.)
The issue we are presently facing with the older WebRTC version used is, If a user initiates a video call in a conference and then stops the camera in the same call, and tries to share the screen, we get an error saying the camera is already in use. The actual WebRTC level error is: "Failed to set local answer sdp: Failed to process the bundled m=section."

Findings: Based on our findings so far, we need to upgrade to a WebRTC library version which has the following fix: 183120: Default streams: don't block media even if on different transceiver.

As a step towards the solution, we tried the following: 1. We were able to compile the latest code by following the instructions given at https://webrtc.github.io/webrtc-org/native-code/ios/. 2. We then replaced the libWebRTC.a for iOS in place of the old dependencies and also copied the relevant CPP and Objective-C include folders. 3. We were able to compile our SDK and CPP code with the new WebRTC library by making necessary changes in the code as per the newer way.

However, we are now facing errors for the RTC logging module. It seems the logging module has a few newer versions of overwritten implementations too. We are not sure how we should arrange these dependencies in our code. Please provide guidance for the same.

Present dependencies are arranged as follows: lib folder -> libWebRTC.a include folder -> cpp folder -> contains respective .h and .cpp files inside relevant folders(e.g. api, rtc_base, call etc) objc folder -> contain respective .h and .mm files inside relevant folders(e.g. api, base, components, Framework, helpers, native etc)

Please guide us about these dependencies arrangements, linkings to resolve the mentioned issue. Following is the screenshot of issues, which are coming for files that are inside include folders, i.e., WebRTC include files inside the CPP folder (logging.h is in rtc_base folder).

Screenshot 2024-03-07 at 6.46.59 PM.png

Kranti Bhange

unread,
Mar 12, 2024, 7:18:42 AM3/12/24
to discuss-webrtc
As one of the trial we checked out M87 code and trying to build using following command, but facing error as mentioned below:

Command: gn gen out/ios --args='target_os="ios" target_cpu="arm64" is_debug=false' --ide=xcode

Error logs:

ERROR at //build_overrides/build.gni:41:13: Script returned non-zero exit code.

  _result = exec_script("//build/mac/should_use_hermetic_xcode.py",

            ^----------

Current dir: /Users/<projectPath>/src/out/ios/

Command: python /Users/<projectPath>/src/build/mac/should_use_hermetic_xcode.py ios

Returned 127.

See //build/toolchain/toolchain.gni:10:1: whence it was imported.

import("//build_overrides/build.gni")

^-----------------------------------

See //build/config/ios/ios_sdk.gni:10:1: whence it was imported.

import("//build/toolchain/toolchain.gni")

^---------------------------------------

See //build/config/sysroot.gni:73:5: whence it was imported.

    import("//build/config/ios/ios_sdk.gni")

    ^--------------------------------------

See //build/config/linux/pkg_config.gni:5:1: whence it was imported.

import("//build/config/sysroot.gni")

^----------------------------------

See //BUILD.gn:15:1: whence it was imported.

import("//build/config/linux/pkg_config.gni")


Can someone guide, how we can compile this old version of code for iOS, by resolving this issue?

Thanks,
Kranti


胡海

unread,
Mar 12, 2024, 9:07:15 PM3/12/24
to discuss...@googlegroups.com
M87 may require python 2.x version, first of all you should make sure that you use the right version of python(e.g. , the directory of ‘depot_tools’ is at the head of ‘PATH’ env variant) .

<Screenshot 2024-03-07 at 6.46.59 PM.png>


-- 
This list falls under the WebRTC Code of Conduct - https://webrtc.org/support/code-of-conduct.
--- 
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/06960b8a-6bdf-4f2d-8dbc-0abee5c1221en%40googlegroups.com.

Kranti Bhange

unread,
Mar 14, 2024, 6:26:06 PM3/14/24
to discuss-webrtc

Thanks a lot for reply 胡海

We used following commands to set python version 2.7:

eval "$(pyenv init -)"

pyenv local 2.7 

Then tried command: gn gen out/ios --args='target_os="ios" target_cpu="arm64" is_debug=false ios_enable_code_signing=false' --ide=xcode

Now facing below error:

ERROR at dynamically parsed input that //build/config/ios/ios_sdk.gni:107:21 loaded :1:20: This is not a valid number.

machine_os_build=23B81

                 --^

See //build/config/sysroot.gni:73:5: whence it was imported.

    import("//build/config/ios/ios_sdk.gni")

    ^--------------------------------------

See //build/config/linux/pkg_config.gni:5:1: whence it was imported.

import("//build/config/sysroot.gni")

^----------------------------------

See //BUILD.gn:15:1: whence it was imported.

import("//build/config/linux/pkg_config.gni")

^-------------------------------------------

Please let us know, if we can try any solution to resolve this issue?

Thanks and regards,
Kranti

Kranti Bhange

unread,
Mar 14, 2024, 6:26:58 PM3/14/24
to discuss-webrtc
Thanks 胡海 for reply.

We tried compiling with python 2.7. Still facing below issue:

Command: gn gen out/ios --args='target_os="ios" target_cpu="arm64" is_debug=false ios_enable_code_signing=false' --ide=xcode

ERROR at dynamically parsed input that //build/config/ios/ios_sdk.gni:107:21 loaded :1:20: This is not a valid number.
machine_os_build=23B81
                 --^

See //build/config/sysroot.gni:73:5: whence it was imported.
    import("//build/config/ios/ios_sdk.gni")
    ^--------------------------------------
See //build/config/linux/pkg_config.gni:5:1: whence it was imported.
import("//build/config/sysroot.gni")
^----------------------------------
See //BUILD.gn:15:1: whence it was imported.
import("//build/config/linux/pkg_config.gni")
^-------------------------------------------

Please suggest, if any solution to resolve this issue.

Thanks and regards,
Kranti
On Wednesday, March 13, 2024 at 6:37:15 AM UTC+5:30 胡海 wrote:

Ayan

unread,
Mar 14, 2024, 6:27:07 PM3/14/24
to discuss-webrtc

Step 1: 

Command used to generate webrtc lib is (from Mac M1): 

gn gen out/ios --args='target_os="ios" target_cpu="arm64" is_debug=false ios_enable_code_signing=false rtc_include_tests=false rtc_enable_symbol_export=true' --ide=xcode

followed by: ninja -C out/ios

Step 2: 
We added libwebrtc.a and required include files to our SDK code and trying to upgrade webrtc lib used in our code. Please help to resolve below issues, if anyone faced the similar kind of issues: How we can define missing architecture from MAC to build code for iOS?

1. File: byte_order.h

Errors:
/Users/user/Documents/Projects/SDK/src/sdk/ios/depends/webrtc_ios/include/cpp/rtc_base/byte_order.h:96:2 "Missing byte order functions for this arch."

2. File: event.h

Error: "Missing byte order functions for this arch." and other errors as in below screenshot:

On Wednesday, March 13, 2024 at 6:37:15 AM UTC+5:30 胡海 wrote:
Screenshot 2024-03-14 at 7.44.32 PM.png

胡海

unread,
Mar 20, 2024, 5:02:28 AM3/20/24
to discuss...@googlegroups.com
Which version of Xcode do you use?Maybe you should try an older version of Xcode, M87 building should be based on an older version Xcode.You can install multiple versions of Xcode in different directories and switch between them with ‘xcode-select’ tool.

Ayan

unread,
Mar 20, 2024, 9:36:55 AM3/20/24
to discuss-webrtc

Hello 胡海, thanks for reply.

We successfully compiled WebRTC_iOS M87 using Xcode 15.1, but encountered difficulties integrating this library into our SDK code. We copied libwebrtc.a to the required location within the SDK.

Our challenge lies in identifying the relevant include files (both CPP and Objective-C) to accompany this static library. The original WebRTC_iOS code contains numerous folders with identical names. We have manually compared and collected the necessary include files from the source of the WebRTC code that we compiled.

We believe that correct linking of the include directory could resolve our compilation issues. However, we are uncertain about the appropriate replacements for the two folders, CPP and Objective-C (objc), as illustrated in the screenshots below. We seek guidance on this matter.

c19b65a0-8a8c-4003-b2c3-68fcdc2d6943.jpg

胡海

unread,
Mar 21, 2024, 9:05:47 PM3/21/24
to discuss...@googlegroups.com
WebRTC define different MACROs for different platforms.On iOS your project that uses webrtc libraries and header files should also define such MACROs used for iOS, e.g., ‘WEBRTC_POSIX’ and ‘WEBRTC_IOS' .

To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/457be39e-b68e-404b-a55e-6e298efb7cfcn%40googlegroups.com.
<c19b65a0-8a8c-4003-b2c3-68fcdc2d6943.jpg>

Eugene Foley

unread,
Mar 24, 2025, 4:54:02 AMMar 24
to discuss-webrtc
I'm currently working on integrating m132 branch into an C++ Library that will be used in my front end IOS App.

I generated an xcodeproj file like so:

gn gen out/ios --args='target_os="ios" target_cpu="arm64" target_environment="device" is_debug=false is_component_build=false rtc_include_tests=false rtc_enable_objc_symbol_export=true ios_enable_code_signing=false ios_deployment_target="18.0" enable_dsyms=false enable_stripping=true rtc_ios_use_opengl_rendering=true' --ide=xcode

And then built a libwebrtc.a  with xcode. 

Im adding into my C++ Library  CMakeLists.txt file:

add_definitions(-DWEBRTC_POSIX) # Resolve "Missing byte order functions for this arch."
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-DWEBRTC_POSIX")

target_link_libraries(
...
path/to/webrtc/src/out/ios/obj/libwebrtc.a
...
)

target_include_directories(
...
path/to/webrtc/src
path/to/webrtc/src/third_party/abseil-cpp
...
)

But this is the odd problem im getting:

in the file: /rtc_base/system/arch.h

I am going down the route:

#elif defined(_M_ARM64) || defined(__aarch64__)

#define WEBRTC_ARCH_ARM_FAMILY

#define WEBRTC_ARCH_64_BITS

#define WEBRTC_ARCH_LITTLE_ENDIAN

But in /rtc_base/byte_order.h I get an error of:

Screenshot 2025-03-23 at 5.25.47 PM.png

I don't hit the error: "#error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined."

So Im thinking that somehow at least either WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN are defined. So i dont know why those functions would not get defined. 

Any guesses?

Thanks in advanced!

Vitaly Ivanov

unread,
Mar 24, 2025, 11:37:19 PMMar 24
to discuss...@googlegroups.com

Eugene Foley

unread,
Mar 26, 2025, 8:46:30 AMMar 26
to discuss-webrtc
Vitaly, 

Thank you that did work for building the C++ framework immediately calling webrtc code, and being used as a library for IOS. 

For posterity this is the modification required to get libwebrtc.a building for IOS properly:

-DWEBRTC_POSIX: Resolve "Missing byte order functions for this arch."
 -DWEBRTC_MAC -DWEBRTC_IOS: Resolve Undeclared Identifier htobe## error

add_definitions(-DWEBRTC_POSIX -DWEBRTC_MAC -DWEBRTC_IOS) 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-DWEBRTC_POSIX -DWEBRTC_MAC -DWEBRTC_IOS")

target_link_libraries(
...
path/to/webrtc/src/out/ios/obj/libwebrtc.a
...
)

target_include_directories(
...
path/to/webrtc/src
path/to/webrtc/src/third_party/abseil-cpp
...
)

The last issue I'm on is integrating the built C++ iOS Framework into Xcode:

Steps followed:

1. Import the C++ iOS Framework into Xcode (lets call it my_core_messenger.framework) as a framework.
2. Setting the "System Header Search Path" to point at 

path/to/webrtc/src [non-recursive]
path/to/webrtc/src/third_party/abseil-cpp [non-recursive]

3. Manual system C++ Flags:

Screenshot 2025-03-25 at 12.05.35 PM.png

4. Set preprocessor define flags:
Screenshot 2025-03-25 at 12.06.45 PM.png

Error when building iOS Project with imported framework my_core_messenger.framework: 

/path/to/webrtc/src/rtc_base/third_party/sigslot/sigslot.h:312:41 No member named 'emitter' in 'sigslot::_opaque_connection'

Screenshot 2025-03-25 at 12.07.58 PM.png

Since my_core_messenger.framework builds without errors in xcode when setup from a CMakeLists.txt but triggering webrtc related errors whne imported into a swift project iOS Fronted that means im missing some flag or define in my Xcode Build Settings but after going over things with a finetoothed comb, I dont see any obvious difference in the relevent build settings.

If anyone has encountered this issue please let me know.

Would love to post a summary of the end-to-end issue-and-solution right back to the forum if i can get this working.

Thank you in advanced, and for the past help offered in this forum!
Reply all
Reply to author
Forward
0 new messages