iOS Catalyst support (M87)

849 views
Skip to first unread message

Filip Bajaník

unread,
Nov 9, 2020, 3:17:16 AM11/9/20
to discuss-webrtc
Hello guys,

I am struggling to build WebRTC for Catalyst, which would enable us to ship our app even for Mac more easily. I can build WebRTC for Mac, but then I am unable to use iOS code base and need to build the Mac app from scratch basically.

I've found an article about how to build it for Catalyst, but it only works for a modified version of WebRTC just with DataChannel:

> Mac-Catalyst is a bit of niche platform, not even major vendors have implemented its support (looking at you Firebase). Essentially, it’s an x86_64 arch just like macOS, but not exactly compatible. You can, in fact, codesign a mac framework, bundle it and dlopen at runtime - and that will work. But that is non-optimal and requires various hacks to use it since you can’t directly reference symbols from it. The proper way is to re-build it for Catalyst.

> Note it only works when applied to data_channel by cdnbye, because it has opengl and other dependencies removed.

Is there any way how to make it build for iOS Catalyst?

It would greatly help us.

Thanks

Filip Bajaník

unread,
Nov 17, 2020, 3:09:22 AM11/17/20
to discuss-webrtc
I sent an email to sdef...@chromium.org who works on Chromium on iOS.
He did not work specifically on WebRTC, but WebRTC shares some of the build templates from Chromium.
He suggested to build it at least with following arguments:

> gn gen out/ios_catalyst --args='target_environment="catalyst" ios_deployment_target="13.0" target_os="ios" treat_warnings_as_errors=false use_xcode_clang=true'

 And it did not provide FW for catalyst, so I've emailed to module owner of iOS build script (tkc...@webrtc.org) and he responded, that he no longer works on WebRTC these days.

So who should I contact to get things moving?

Dátum: pondelok 9. novembra 2020, čas: 9:17:16 UTC+1, odosielateľ: Filip Bajaník

Zeke Chin

unread,
Nov 17, 2020, 1:21:47 PM11/17/20
to discuss-webrtc, kthel...@webrtc.org
+kthe...@webrtc.org might be able to help point you in the right direction. However, it seems likely that building for catalyst would require extra work outside of build arguments if it didn't already work for you. 

--

---
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/88ce620b-ebef-4859-a4b0-9ebc7848b335n%40googlegroups.com.

Filip Bajaník

unread,
Nov 26, 2020, 3:09:12 AM11/26/20
to discuss-webrtc
Nobody has responded unfortunately yet. Do you know someone else that can help me? Thanks

Dátum: utorok 17. novembra 2020, čas: 19:21:47 UTC+1, odosielateľ: Zeke Chin

maciek....@gmail.com

unread,
Jan 13, 2021, 2:56:16 PM1/13/21
to discuss-webrtc
Did you make any progress with this issue? I'll be facing same problem soon (~2 weeks) and I'm doing initial research. Did you see this article?

Filip Bajaník

unread,
Jan 14, 2021, 9:34:38 AM1/14/21
to discuss-webrtc
I've seen that, no luck with that so far... nobody has responded since than.

Dátum: streda 13. januára 2021, čas: 20:56:16 UTC+1, odosielateľ: maciek....@gmail.com

Maciej Kupczak

unread,
Jan 16, 2021, 9:39:48 AM1/16/21
to discuss...@googlegroups.com
Filip,

I had worked on this today and I'm happy to report success :) Specifically, I'm able to produce what I need: libwebrtc.a with support for data channels and audio tracks working in Mac Catalyst 14.1+. Here is what I ended up with:

* latest stable Xcode (12.3 12C33)
* latest stable WebRTC release branch (88 release, branch branch-heads/4324, commit b15b29151fe3a2affe70ee584fdb015c60ce4f6a)
* two files changed (see attachments): 
* sdk/BUILD.gn (exclude whatever video-related stuff that was generating errors you mentioned, the ones related to OpenGL usage)
* build/config/ios/codesign.py (in this one I just did whatever it took for ninja to pass generating/signing WebRTC.framework which I don't need)
* gn command: gn gen out/catalyst_x64 --args='target_os="ios" target_cpu="x64" rtc_include_builtin_video_codecs=false rtc_include_tests=false rtc_build_examples=false rtc_build_tools=false ios_enable_code_signing=false ios_deployment_target="14.1" use_xcode_clang=true target_environment="catalyst"'
* ninja command: ninja -C out/catalyst_x64 webrtc

And that's it ¯\_(ツ)_/¯

I think the biggest remaining blocker of compiling full framework (with video) is refactoring sdk/BUILD.gn, not sdk codebase. It seems Metal renderer is ready (in sdk/components/rendering/metal) and I guess it's working, but OpenGL one is always included, which is what's problematic. Beside that, there are some unavailable in MacCatalyst CoreVideo constants (related to OpenGL) being used in some codecs, but it also shouldn't be major issue.

I hope it helps you with moving forward,
Maciek

You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/VZXS4V4mSY4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/77d55fe1-a0b1-4efb-b6b7-73d2a775dd0an%40googlegroups.com.
codesign.py
BUILD.gn

Filip Bajaník

unread,
Jan 22, 2021, 5:57:39 AM1/22/21
to discuss-webrtc
Thank you for your observations and work. I forgot to mention that my goal was to make it fully work, which includes both audio and video streams working on which I haven't succeed so far.
It is very time demanding to fix those build config issues, so I asked for help.
Dátum: sobota 16. januára 2021, čas: 15:39:48 UTC+1, odosielateľ: maciek....@gmail.com

Filip Bajaník

unread,
Mar 11, 2021, 10:09:58 AM3/11/21
to discuss-webrtc
I successfully removed OpenGL stuff, but still the resulting framework can't find symbols 
- Undefined symbols for architecutre x86_64: "_OBJC_CLASS_$_RTCPeerConnectionFactory" etc.

It was compiled with the right architecture, target, iframework and isysroot.

peerconnection.ninja as an example:
```
defines = -DCR_XCODE_VERSION=1240 -DCR_CLANG_REVISION=\"llvmorg-13-init-1559-g01b87444-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DNS_BLOCK_ASSERTIONS=1 -DWEBRTC_ENABLE_PROTOBUF=1 -DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE -DWEBRTC_HAVE_SCTP -DWEBRTC_LIBRARY_IMPL -DWEBRTC_ENABLE_AVX2 -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_POSIX -DWEBRTC_MAC -DWEBRTC_IOS -DABSL_ALLOCATOR_NOTHROW=1 -DWEBRTC_HAVE_SCTP
framework_dirs =
include_dirs = -I../.. -Igen -I../../third_party/abseil-cpp -I../../third_party/libyuv/include
cflags = -fno-delete-null-pointer-checks -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fcolor-diagnostics -fmerge-all-constants -target x86_64-apple-ios13.2-macabi -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -Wall -Werror -Wextra -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi -Wunguarded-availability -Wundeclared-selector -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Oz -fno-omit-frame-pointer -g2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/usr/include -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wglobal-constructors -Wc++11-narrowing -Wimplicit-fallthrough -Wthread-safety -Winconsistent-missing-override -Wundef -Wno-shorten-64-to-32
cflags_cc = -std=c++14 -fno-trigraphs -Wno-trigraphs -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -Wnon-virtual-dtor -Woverloaded-virtual
label_name = peerconnection
target_gen_dir = gen/pc
target_out_dir = obj/pc
target_output_name = libpeerconnection

... and the rest
```
-target x86_64-apple-ios13.2-macabi
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/usr/include
-iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks

What else should be setup? :( I just can't successfully make it work even the framework is builded for Catalyst.

Dátum: piatok 22. januára 2021, čas: 11:57:39 UTC+1, odosielateľ: Filip Bajaník
Reply all
Reply to author
Forward
0 new messages