WebRTC 通用二进制文件

这是用于 iOS 和 macOS 的 XCFramework 格式的 WebRTC 框架。

Google 提供了 iOS 的官方构建版本。如果只需要 iOS 版本,请从 Google 获取。

安装

手动安装

Release 处下载 XCFramework,并将其拖动到您的 Xcode 项目中。

Swift 包管理器

需要 Swift 5.3 / Xcode 12 及更高版本。

通过 Swift 包管理器添加 WebRTC 仓库 https://github.com/alexpiezo/WebRTC.git

或者,要通过 Package.swift 清单而不是 Xcode 进行集成,您可以将 WebRTC 添加到包的 dependencies 数组中,如下所示:

dependencies: [
    .package(url: "https://github.com/alexpiezo/WebRTC.git", .upToNextMajor(from: "1.1.31567"))
]

然后将新的运行脚本阶段脚本添加到您的应用程序的目标中

find "${CODESIGNING_FOLDER_PATH}" -name '*.framework' -print0 | while read -d $'\0' framework 
do 
    codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements --timestamp=none "${framework}" 
done

手动构建您自己的版本

下载 WebRTC

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/path/to/depot_tools

fetch --nohooks webrtc_ios

git branch -r
git checkout branch-heads/BRANCH

gclient sync

生成 iOS 和 macOS 目标

gn gen ../out/mac_x64 --args='target_os="mac" target_cpu="x64" is_component_build=false is_debug=false rtc_libvpx_build_vp9=false enable_stripping=true rtc_enable_protobuf=false'

gn gen ../out/ios_arm64 --args='target_os="ios" target_cpu="arm64" is_component_build=false use_xcode_clang=true is_debug=false  ios_deployment_target="10.0" rtc_libvpx_build_vp9=false use_goma=false ios_enable_code_signing=false enable_stripping=true rtc_enable_protobuf=false enable_ios_bitcode=false treat_warnings_as_errors=false'

gn gen ../out/ios_x64 --args='target_os="ios" target_cpu="x64" is_component_build=false use_xcode_clang=true is_debug=true ios_deployment_target="10.0" rtc_libvpx_build_vp9=false use_goma=false ios_enable_code_signing=false enable_stripping=true rtc_enable_protobuf=false enable_ios_bitcode=false treat_warnings_as_errors=false'

构建目标

ninja -C out/mac_x64 sdk:mac_framework_objc
ninja -C out/ios_arm64 sdk:framework_objc
ninja -C out/ios_x64 sdk:framework_objc

生成 XCFramework

xcodebuild -create-xcframework \
	-framework out/ios_arm64/WebRTC.framework \
	-framework out/ios_x64/WebRTC.framework \
	-framework out/mac_x64/WebRTC.framework \
	-output out/WebRTC.xcframework