### Installation Commands Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Provides examples of commands for installing WebRTC via different package managers. Covers Swift Package Manager, CocoaPods, and Carthage. ```bash # Installation commands # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Verification Commands Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Includes example commands to verify the WebRTC installation and build. Helps ensure the setup is correct. ```bash # Verification commands # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Swift RTCPeerConnectionFactory Setup Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Demonstrates the basic setup for RTCPeerConnectionFactory in Swift. This is a common starting point for WebRTC applications. ```swift // Swift RTCPeerConnectionFactory setup // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Build Commands Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Shows example commands for building the WebRTC framework or project. Essential for integrating and compiling the library. ```bash # Build commands # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Example WebRTC Package URL Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/package-configuration.md An example of a specific package distribution URL for release M149. ```text https://github.com/stasel/WebRTC/releases/download/149.0.0/WebRTC-M149.xcframework.zip ``` -------------------------------- ### Podfile Configurations Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Provides examples of different Podfile configurations for CocoaPods dependency management. Used for integrating libraries in iOS projects. ```ruby # Podfile configurations # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Minimal Peer Connection Setup in Swift Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/README.md This snippet demonstrates the basic setup for a peer connection in Swift using the WebRTC library. It includes configuring the audio session, creating a peer connection factory, setting up ICE servers, and initializing the peer connection with constraints and a delegate. ```swift import UIKit import WebRTC class VideoCallViewController: UIViewController { var factory: RTCPeerConnectionFactory? var peerConnection: RTCPeerConnection? override func viewDidLoad() { super.viewDidLoad() setupPeerConnection() } func setupPeerConnection() { // Configure audio session let audioSession = RTCAudioSession.sharedInstance() audioSession.lockForConfiguration() try? audioSession.setCategory(AVAudioSession.Category.default.rawValue) audioSession.unlockForConfiguration() // Create factory factory = RTCPeerConnectionFactory( encoderFactory: RTCDefaultVideoEncoderFactory(), decoderFactory: RTCDefaultVideoDecoderFactory() ) // Create configuration let config = RTCConfiguration() config.iceServers = [RTCIceServer(urlStrings: ["stun:stun.l.google.com:19302"])] // Create peer connection peerConnection = factory?.peerConnection( with: config, constraints: RTCMediaConstraints(), delegate: self ) } } extension VideoCallViewController: RTCPeerConnectionDelegate { func peerConnection(_ peerConnection: RTCPeerConnection, didChange stateChanged: RTCSignalingState) { print("Signaling state: \(stateChanged.rawValue)") } func peerConnection(_ peerConnection: RTCPeerConnection, didGenerate candidate: RTCIceCandidate) { print("New ICE candidate: \(candidate.candidate)") // Send to remote peer via signaling mechanism } } ``` -------------------------------- ### Objective-C WebRTC Initialization Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Provides an example of initializing WebRTC components using Objective-C. Necessary for Objective-C projects integrating WebRTC. ```objectivec // Objective-C WebRTC initialization // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Debugging Commands Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Lists example commands used for debugging WebRTC issues. Useful for diagnosing runtime errors and build failures. ```bash # Debugging commands # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Build Settings Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Demonstrates typical build settings configurations. These settings are crucial for compiling and linking projects correctly. ```plaintext # Build settings # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Example WebRTC Release Description Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/release-notes-template.md This example shows the typical content found in a WebRTC release description on GitHub, including links to release notes, branch information, commit hashes, and checksums. ```text Release notes: https://webrtc.googlesource.com/src.git/+log/refs/branch-heads/7727/ WebRTC Branch: [branch-heads/7727](https://chromium.googlesource.com/external/webrtc/+log/branch-heads/7727) WebRTC Commit: `1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b` SHA 256 checksum: `79c5a3e49a68de30a99baabaf5b4c0067dd7a0b66fdd4b8afb8ec337e746abba` ``` -------------------------------- ### Setup Depot Tools for WebRTC Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Downloads and sets up the depot_tools repository, which is essential for WebRTC development. Adds depot_tools to the system's PATH. ```bash git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ``` -------------------------------- ### Install Latest WebRTC with SPM Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Use this for CI/CD pipelines and always-current builds with Swift Package Manager. ```swift .package(url: "https://github.com/stasel/WebRTC.git", branch: "latest") ``` -------------------------------- ### Cartfile Examples Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Illustrates various examples of Cartfile content for Carthage dependency management. Used for managing dependencies in macOS and iOS projects. ```plaintext # Cartfile examples # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Verify WebRTC Framework Installation Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Check if the WebRTC framework has been correctly installed within the Pods directory. This command lists the contents of the WebRTC framework folder. ```bash ls Pods/WebRTC-lib/WebRTC.xcframework/ ``` -------------------------------- ### Configure Post-Install Hook in Podfile Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Example of a `post_install` hook in a Podfile. Ensure it avoids conflicting configurations, especially for WebRTC, to prevent build errors. ```ruby post_install do |installer| installer.pods_project.targets.each do |target| # Only include necessary configurations target.build_configurations.each do |config| # Avoid duplicate WebRTC configurations end end end ``` -------------------------------- ### Package.swift Variations Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Shows different configurations and variations for Package.swift files. Used for managing Swift package dependencies. ```swift // Package.swift variations // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### GN Arguments Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Shows examples of GN (Generate Ninja) arguments used in the build system. GN is used for configuring the build process of native WebRTC components. ```plaintext # GN arguments # (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Update CocoaPods and Install Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Run these commands to update your local pod specifications and then install dependencies, resolving potential issues with outdated pod data. ```bash pod repo update pod install --repo-update ``` -------------------------------- ### Swift RTCPeerConnection Initialization Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Illustrates how to initialize an RTCPeerConnection object in Swift. Essential for establishing peer-to-peer connections. ```swift // Swift RTCPeerConnection initialization // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Force Reinstall Pods with Repo Update Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md A comprehensive step to resolve 'WebRTC.h not found' errors by cleaning previous installations and performing a fresh install with updated repositories. ```bash rm -rf Pods Podfile.lock pod install --repo-update ``` -------------------------------- ### Install Cocoapods Dependencies Source: https://github.com/stasel/webrtc/blob/latest/README.md Run this command in your terminal after adding the 'WebRTC-lib' pod to your Podfile. ```bash pod install ``` -------------------------------- ### Bash: Open Workspace after Pod Install Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Always open the generated `.xcworkspace` file after running `pod install` to work with your project and its dependencies. ```bash open MyApp.xcworkspace ``` -------------------------------- ### Quick Peer Connection Setup in Swift Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/START_HERE.md Use this snippet to quickly initialize a peer connection factory, configure ICE servers, and create a peer connection object. Ensure you have imported the WebRTC framework. ```swift import WebRTC // Create factory let factory = RTCPeerConnectionFactory( encoderFactory: RTCDefaultVideoEncoderFactory(), decoderFactory: RTCDefaultVideoDecoderFactory() ) // Create configuration let config = RTCConfiguration() config.iceServers = [RTCIceServer(urlStrings: ["stun:stun.l.google.com:19302"])] // Create peer connection let peerConnection = factory.peerConnection( with: config, constraints: RTCMediaConstraints(), delegate: self ) ``` -------------------------------- ### Info.plist Entries Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Illustrates necessary entries for the Info.plist file. Required for specifying application permissions and configurations on Apple platforms. ```xml ``` -------------------------------- ### Example M149 Changelog Source Link Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/release-notes-template.md This is an example URL pointing to the commit log for the M149 release branch. It allows developers to inspect all changes included in that specific release. ```url https://webrtc.googlesource.com/src.git/+log/refs/branch-heads/7727/ ``` -------------------------------- ### Objective-C Delegates Implementation Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to implement delegates for WebRTC callbacks in Objective-C. Crucial for handling connection events and data. ```objectivec // Objective-C delegates implementation // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Objective-C WebRTC Connection Setup Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md This snippet demonstrates how to set up a basic WebRTC connection in an Objective-C application. It covers configuring the audio session, creating the RTCPeerConnectionFactory, setting up the RTCPeerConnection with ICE servers, and establishing a data channel for messaging. Ensure you have the WebRTC framework imported. ```objc #import @import WebRTC; @interface VideoCallViewController : UIViewController < RTCPeerConnectionDelegate, RTCDataChannelDelegate > @property (nonatomic, strong) RTCPeerConnectionFactory *factory; @property (nonatomic, strong) RTCPeerConnection *peerConnection; @property (nonatomic, strong) RTCDataChannel *dataChannel; @end @implementation VideoCallViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupWebRTC]; } - (void)setupWebRTC { // Configure audio session RTCAudioSession *audioSession = [RTCAudioSession sharedInstance]; [audioSession lockForConfiguration]; [audioSession setCategory:AVAudioSessionCategoryDefault error:nil]; [audioSession unlockForConfiguration]; // Create factory with default video codecs self.factory = [[RTCPeerConnectionFactory alloc] initWithEncoderFactory:[[RTCDefaultVideoEncoderFactory alloc] init] decoderFactory:[[RTCDefaultVideoDecoderFactory alloc] init] ]; // Configure peer connection RTCConfiguration *config = [[RTCConfiguration alloc] init]; config.iceServers = @[ [[RTCIceServer alloc] initWithURLStrings:@["stun:stun.l.google.com:19302"]] ]; RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:nil optionalConstraints:nil ]; self.peerConnection = [self.factory peerConnectionWithConfiguration:config constraints:constraints delegate:self]; // Create data channel RTCDataChannelConfiguration *dcConfig = [[RTCDataChannelConfiguration alloc] init]; dcConfig.isOrdered = YES; self.dataChannel = [self.peerConnection dataChannelForLabel:@ ``` ```objc messaging" configuration:dcConfig]; self.dataChannel.delegate = self; } #pragma mark - RTCPeerConnectionDelegate - (void)peerConnection:(RTCPeerConnection *)peerConnection didChangeSignalingState:(RTCSignalingState)stateChanged { NSLog(@"Signaling state: %ld", (long)stateChanged); } - (void)peerConnection:(RTCPeerConnection *)peerConnection didAddStream:(RTCMediaStream *)stream { NSLog(@"Stream added: %@", stream.streamId); } - (void)peerConnection:(RTCPeerConnection *)peerConnection didChangeIceConnectionState:(RTCIceConnectionState)newState { NSLog(@"ICE connection state: %ld", (long)newState); } - (void)peerConnection:(RTCPeerConnection *)peerConnection didGenerateIceCandidate:(RTCIceCandidate *)candidate { NSLog(@"ICE candidate: %@", candidate.candidate); } #pragma mark - RTCDataChannelDelegate - (void)dataChannelDidChangeState:(RTCDataChannel *)dataChannel { NSLog(@"Data channel state: %ld", (long)dataChannel.readyState); } - (void)dataChannel:(RTCDataChannel *)dataChannel didReceiveMessageWithBuffer:(RTCDataBuffer *)buffer { NSString *message = [[NSString alloc] initWithData:buffer.data encoding:NSUTF8StringEncoding]; NSLog(@"Received: %@", message); } @end ``` -------------------------------- ### Swift Package Manager Version Constraints Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/release-notes-template.md Examples of how to define version constraints for the WebRTC package in Package.swift. ```swift .upToNextMajor("149.0.0") // Allows 149.x.x, not 150.x ``` ```swift .range("149.0.0"..<"150.0.0") // Same as above ``` ```swift .exact("149.0.0") // Only 149.0.0 ``` ```swift branch: "latest" // Always latest stable ``` -------------------------------- ### Create New iOS App Project Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md Use this command to create a new iOS application project. Ensure Xcode is installed and accessible. ```bash # Create new iOS app project open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app # Or: File → New → Project in Xcode # Select: iOS → App # Language: Swift # Name: WebRTCDemo ``` -------------------------------- ### CocoaPods: Multiple Targets Configuration Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Example Podfile configuration for managing dependencies across multiple targets, such as separate iOS and macOS applications. ```ruby target 'iOS App' do platform :ios, '12.0' pod 'WebRTC-lib' end target 'macOS App' do platform :macos, '10.11' pod 'WebRTC-lib' end ``` -------------------------------- ### Swift Signaling Client (WebSocket) Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Illustrates a signaling client implementation using WebSockets in Swift. Signaling is required to coordinate peer connections. ```swift // Swift signaling client (WebSocket) // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Install Stable WebRTC v149 with SPM Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Pin to a specific major version for production stability using Swift Package Manager. ```swift .package(url: "https://github.com/stasel/WebRTC.git", .upToNextMajor("149.0.0")) ``` -------------------------------- ### Reinstall Pods with Repo Update Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Install pods after cleaning and updating repositories. The `--repo-update` flag ensures the latest specs are used. ```bash pod install --repo-update ``` -------------------------------- ### Code-sign Simulator Framework Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Use this command to code-sign the WebRTC framework for the iOS Simulator if manual installation is performed. Ensure the path to the framework is correct. ```bash codesign -s - --deep --force WebRTC.xcframework/ios-x86_64-arm64-simulator/WebRTC.framework ``` -------------------------------- ### Clean and Reinstall Pods Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Remove existing Pods and lock file, then reinstall. This is a common step to resolve various installation and linking issues. ```bash rm -rf Pods rm -rf Podfile.lock pod install ``` -------------------------------- ### WebRTC Release Workflow Diagram Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md This diagram illustrates the automated steps involved in the WebRTC release process, starting from fetching release information to creating a pull request. ```text ┌─────────────────────────────────┐ │ Fetch next release info │ │ (getNextRelease) │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Check release date available │ │ (isReleaseAvailable) │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Build WebRTC (buildWebRTC) │ │ - iOS device & simulator │ │ - macOS (Intel & Apple Silicon) │ │ - macOS Catalyst │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Read build metadata │ │ (getBuildMetadata) │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Create GitHub release draft │ │ (createReleaseDraft) │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Upload xcframework archive │ │ (uploadReleaseAsset) │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Create feature branch │ │ git checkout -b release-M{X} │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Update package files │ │ - Package.swift │ │ - WebRTC-lib.podspec │ │ - README.md │ │ - WebRTC.json │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Commit and push │ │ git push origin release-M{X} │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ Create pull request │ │ (createPullRequest) │ └─────────────────────────────────┘ ``` -------------------------------- ### Build and Run Commands Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md Standard Xcode shortcuts for building and running the project on a simulator or device. ```bash # Build the project Cmd+B # Run on simulator Cmd+R # Or on device (with provisioning profile) Cmd+R (select device) ``` -------------------------------- ### Download and Sync WebRTC Source Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Initializes the WebRTC repository and downloads all necessary dependencies. Ensure you are in the correct directory before running. ```bash fetch --nohooks webrtc_ios cd src git fetch --all git checkout $BRANCH gclient sync --with_branch_heads --with_tags ``` -------------------------------- ### Bash: Initialize CocoaPods Project Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Create a new Podfile for your project using the `pod init` command if one does not already exist. ```bash cd /path/to/your/project pod init ``` -------------------------------- ### Add Cocoapods Dependency Source: https://github.com/stasel/webrtc/blob/latest/README.md Add the 'WebRTC-lib' pod to your Podfile for installation via Cocoapods. ```ruby pod 'WebRTC-lib' ``` -------------------------------- ### Test Build and Run Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md Use these keyboard shortcuts in Xcode to build and run your application on a simulator. ```bash Cmd+B (Build) Cmd+R (Run on simulator) ``` -------------------------------- ### Build WebRTC for Multiple Platforms Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Execute the main build script with environment variables to specify platforms and branches for compilation. ```bash cd /workspace/webrtc BRANCH=branch-heads/7727 MACOS=true IOS=true MAC_CATALYST=true sh scripts/build.sh ``` -------------------------------- ### Basic WebRTC Implementation in Swift Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md This Swift code sets up the core WebRTC components including the peer connection factory, configuration with STUN servers, media constraints, peer connection, and a data channel for messaging. It also includes delegate methods for handling signaling and ICE state changes, as well as data channel events. ```swift import UIKit import WebRTC class VideoCallViewController: UIViewController { var peerConnectionFactory: RTCPeerConnectionFactory? var peerConnection: RTCPeerConnection? var localDataChannel: RTCDataChannel? override func viewDidLoad() { super.viewDidLoad() setupWebRTC() } func setupWebRTC() { // Initialize the WebRTC peer connection factory let rtcAudioSession = RTCAudioSession.sharedInstance() rtcAudioSession.lockForConfiguration() try! rtcAudioSession.setCategory(AVAudioSession.Category.default.rawValue) rtcAudioSession.unlockForConfiguration() peerConnectionFactory = RTCPeerConnectionFactory( encoderFactory: RTCDefaultVideoEncoderFactory(), decoderFactory: RTCDefaultVideoDecoderFactory() ) // Create peer connection configuration let config = RTCConfiguration() config.iceServers = [ RTCIceServer(urlStrings: ["stun:stun.l.google.com:19302"]) ] // Create constraints let constraints = RTCMediaConstraints( mandatoryConstraints: nil, optionalConstraints: nil ) // Create peer connection peerConnection = peerConnectionFactory?.peerConnection( with: config, constraints: constraints, delegate: self ) // Create data channel let dataChannelConfig = RTCDataChannelConfiguration() dataChannelConfig.isOrdered = true if let dataChannel = peerConnection?.dataChannel( forLabel: "messaging", configuration: dataChannelConfig ) { localDataChannel = dataChannel dataChannel.delegate = self } } } // MARK: - RTCPeerConnectionDelegate extension VideoCallViewController: RTCPeerConnectionDelegate { func peerConnection( _ peerConnection: RTCPeerConnection, didChange stateChanged: RTCSignalingState ) { print("Signaling state changed: \(stateChanged.rawValue)") } func peerConnection( _ peerConnection: RTCPeerConnection, didAdd stream: RTCMediaStream ) { print("Stream added: \(stream.streamId)") } func peerConnection( _ peerConnection: RTCPeerConnection, didRemove stream: RTCMediaStream ) { print("Stream removed: \(stream.streamId)") } func peerConnection( _ peerConnection: RTCPeerConnection, didChange newState: RTCIceConnectionState ) { print("ICE connection state: \(newState.rawValue)") } func peerConnection( _ peerConnection: RTCPeerConnection, didChange newState: RTCIceGatheringState ) { print("ICE gathering state: \(newState.rawValue)") } func peerConnection( _ peerConnection: RTCPeerConnection, didGenerate candidate: RTCIceCandidate ) { print("ICE candidate: \(candidate.candidate)") // Send candidate to remote peer via signaling } func peerConnection( _ peerConnection: RTCPeerConnection, didRemove candidates: [RTCIceCandidate] ) { print("ICE candidates removed") } func peerConnectionShouldNegotiate(_ peerConnection: RTCPeerConnection) { print("Renegotiation needed") } func peerConnection( _ peerConnection: RTCPeerConnection, didAdd rtcStatsReport: RTCStatsReport ) { print("Stats report received") } } // MARK: - RTCDataChannelDelegate extension VideoCallViewController: RTCDataChannelDelegate { func dataChannelDidChangeState(_ dataChannel: RTCDataChannel) { print("Data channel state: \(dataChannel.readyState.rawValue)") } func dataChannel( _ dataChannel: RTCDataChannel, didReceiveMessageWith buffer: RTCDataBuffer ) { let message = String(data: buffer.data, encoding: .utf8) ?? "" print("Received message: \(message)") } } ``` -------------------------------- ### Update CocoaPods Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Update CocoaPods to the latest version to resolve potential installation issues. Run this command in your terminal. ```bash sudo gem install cocoapods ``` -------------------------------- ### Clean and Build Project Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md Commands to resolve 'Module 'WebRTC' not found' errors by cleaning the project and resetting package caches. ```bash File → Packages → Reset Package Caches Cmd+Shift+K (Clean) Cmd+B (Build) ``` -------------------------------- ### Get Stable Chromium Milestone Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Fetches the current stable Chromium milestone number. Returns None if the fetch fails. ```python stable = getStableMilestone() # Returns: 149 ``` -------------------------------- ### Swift: Initialize WebRTC Configuration (CocoaPods) Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Import the WebRTC framework and initialize the RTCPeerConnectionFactory, preparing to configure RTC settings in Swift. ```swift import WebRTC class VideoCallViewController: UIViewController { let factory = RTCPeerConnectionFactory() func setupRTC() { let config = RTCConfiguration() // Configure... } } ``` -------------------------------- ### Configure Package.swift Version Constraints Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Demonstrates correct and incorrect ways to specify version constraints for packages in Package.swift. ```swift // ❌ Too restrictive .package(url: "...", .exact("149.0.0")) // ✅ Flexible .package(url: "...", .upToNextMajor("149.0.0")) // ✅ Latest .package(url: "...", branch: "latest") ``` -------------------------------- ### Swift: Import WebRTC and Initialize Factory Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Import the WebRTC framework in your Swift code and initialize the RTCPeerConnectionFactory to begin creating peer connections. ```swift import WebRTC class VideoCallViewController: UIViewController { let peerConnection: RTCPeerConnection? func setupPeerConnection() { let factory = RTCPeerConnectionFactory() // Use factory to create connections } } ``` -------------------------------- ### List Architectures using lipo Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md Use the `lipo -info` command to display the architectures contained within a universal Mach-O binary. ```bash lipo -info WebRTC.framework/WebRTC # Output: Architectures in the fat file: WebRTC.framework/WebRTC are: x86_64 arm64 ``` -------------------------------- ### Update Pod Repositories Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Refresh local pod specifications to ensure you are using the latest available versions. Execute this command before installing pods. ```bash pod repo update ``` -------------------------------- ### Swift RTCDataChannel Usage Example Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/COMPLETION_SUMMARY.txt Shows how to use RTCDataChannel for sending and receiving arbitrary data between peers in Swift. Useful for chat or game data. ```swift // Swift RTCDataChannel usage // (Example code not provided in source, but listed as covered) ``` -------------------------------- ### Swift Usage of WebRTC Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md Import the WebRTC module and initialize the factory and configuration objects in Swift. ```swift import WebRTC let factory = RTCPeerConnectionFactory() let config = RTCConfiguration() ``` -------------------------------- ### Get Build Metadata Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Reads the metadata.json file generated by the build script to retrieve build details like filename, checksum, commit, and branch. ```python buildMetadata(outputDir) # Returns: BuildMetadata dataclass ``` -------------------------------- ### Clear Derived Data and Pods Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Remove outdated build artifacts and the Pods directory to ensure a clean installation. This helps resolve issues caused by corrupted or stale dependencies. ```bash rm -rf ~/Library/Developer/Xcode/DerivedData rm -rf Pods rm -rf Podfile.lock ``` -------------------------------- ### Extracting WebRTC Framework Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md Unzip the WebRTC framework archive to make it available for Xcode. ```bash unzip WebRTC-M149.xcframework.zip # Produces: WebRTC.xcframework/ ``` -------------------------------- ### WebRTC Import Styles Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md Illustrates different ways to import the WebRTC framework in Swift and Objective-C. ```swift import WebRTC // Module import (preferred) ``` ```objective-c @import WebRTC; ``` ```objective-c #import // Traditional header import ``` -------------------------------- ### Build WebRTC Artifacts Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Executes the build script for WebRTC with all platforms enabled. Requires the BRANCH environment variable to be set. ```bash buildWebRTC(branch) # Returns: bool (True if build.sh exits with code 0) ``` -------------------------------- ### Download WebRTC xcframework Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Download the latest xcframework from GitHub Releases. ```bash https://github.com/stasel/WebRTC/releases ``` -------------------------------- ### Simulator Permissions for Camera and Microphone Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/integration-quickstart.md Add these keys to your Info.plist file to grant simulators access to camera and microphone for video calls. ```xml NSCameraUsageDescription This app needs access to your camera for video calls NSMicrophoneUsageDescription This app needs access to your microphone for video calls ``` -------------------------------- ### Copy License File to XCFramework Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/build-system.md Copies the BSD license file into the XCFramework directory. This ensures licensing information is included with the built framework. ```bash cp LICENSE ${XCFRAMEWORK_DIR} ``` -------------------------------- ### iOS Simulator (arm64 + x86_64) Architecture Details Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md Details for the iOS simulator binary, which is a universal binary containing both x86_64 and arm64 architectures. ```text Universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64:Mach-O 64-bit dynamically linked shared library arm64] ``` -------------------------------- ### Objective-C: Import WebRTC and Initialize Factory Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Import the WebRTC framework in your Objective-C code and initialize the RTCPeerConnectionFactory for creating peer connections. ```objectivec @import WebRTC; @interface VideoCallViewController : UIViewController @property (nonatomic, strong) RTCPeerConnection *peerConnection; @end @implementation VideoCallViewController - (void)setupPeerConnection { RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init]; // Use factory to create connections } @end ``` -------------------------------- ### Check WebRTC Framework Architecture Slices Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Verifies that the WebRTC.xcframework includes the necessary architecture slices for both physical devices (e.g., `ios-arm64`) and simulators (e.g., `ios-x86_64_arm64-simulator`). This is important for apps that build on the simulator but crash on a device. ```bash ls WebRTC.xcframework/ # Should contain: ios-arm64/ (device) # ios-x86_64_arm64-simulator/ (simulator) ``` -------------------------------- ### Conditional WebRTC Initialization for Previews Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md This Swift code demonstrates how to conditionally initialize WebRTC only when the application is running, not during SwiftUI Previews. This prevents 'Unable to instantiate RTCPeerConnectionFactory' errors in previews. ```swift #if DEBUG // Only initialize WebRTC in actual app, not preview @main struct MyApp: App { @State var callManager: CallManager? init() { #if !PREVIEW_MODE self.callManager = CallManager() #endif } var body: some Scene { WindowGroup { ContentView() } } } #endif ``` -------------------------------- ### Clean and Build Project Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Perform a clean build after resetting caches to ensure a fresh project state. ```Xcode Cmd+Shift+K (Clean) Cmd+B (Build) ``` -------------------------------- ### Objective-C Usage of WebRTC Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md Import the WebRTC module and initialize the factory object in Objective-C. ```objc @import WebRTC; // or #import RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init]; ``` -------------------------------- ### Add Carthage Build Phase in Xcode Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Configure your Xcode project to include the WebRTC framework. This can be done via the 'Frameworks, Libraries, and Embedded Content' section or a 'Copy Files' build phase. ```bash /usr/local/bin/carthage copy-frameworks # Input files $(SRCROOT)/Carthage/Build/WebRTC.xcframework # Output files $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/WebRTC.xcframework ``` -------------------------------- ### Check Disk Space Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Verify available disk space on the root partition, ensuring at least 5GB is free for builds and archives. ```bash df -h / # Ensure at least 5GB free ``` -------------------------------- ### CocoaPods: Development from Source Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md For testing or development purposes, specify the 'WebRTC-lib' pod to be fetched directly from its Git repository and branch. ```ruby pod 'WebRTC-lib', :git => 'https://github.com/stasel/WebRTC.git', :branch => 'latest' ``` -------------------------------- ### Verify xcframework Architecture Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/platform-support.md Use `xcframework info` to check if the WebRTC xcframework includes the necessary architecture slices, particularly for Apple Silicon compatibility. ```bash xcframework info WebRTC.xcframework ``` -------------------------------- ### Check Binary Architecture Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/platform-support.md Use `lipo -info` to inspect the architecture information of a binary, useful for diagnosing issues related to architecture mismatches. ```bash lipo -info WebRTC.framework/WebRTC ``` -------------------------------- ### Verify WebRTC Framework Architecture Compatibility Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Check if the WebRTC framework contains the necessary architectures for the target platform (simulator or device). This helps diagnose 'dyld: Symbol not found' errors. ```bash # For simulator, verify xcframework contains architectures: file Pods/WebRTC-lib/WebRTC.xcframework/ios-*/WebRTC.framework/WebRTC # Should show: arm64, x86_64 (depending on platform) ``` -------------------------------- ### Pin WebRTC Version for Legacy Projects (Swift) Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/README.md Use `.exact()` to pin a specific version of the WebRTC package for legacy projects, ensuring stability. ```swift .package(url: "https://github.com/stasel/WebRTC.git", .exact("140.0.0")) ``` -------------------------------- ### Swift Package Manager Dependency Usage Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/package-configuration.md Shows how to add the WebRTC package to your project's dependencies in Package.swift and link it to your target. ```swift // In your Package.swift dependencies: dependencies: [ .package(url: "https://github.com/stasel/WebRTC.git", .upToNextMajor("149.0.0")) ] // In your target dependencies: .target( name: "YourTarget", dependencies: ["WebRTC"]) ``` -------------------------------- ### WebRTC Framework Directory Structure Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/framework-structure.md The standard Apple framework bundle structure for WebRTC, containing the dynamic library, public headers, module map, and metadata. ```text WebRTC.framework/ ├── WebRTC # Mach-O binary (dynamic library) ├── Headers/ # Public header files │ └── *.h ├── Modules/ # Swift module map │ └── module.modulemap └── Info.plist # Framework metadata ``` -------------------------------- ### Configure SPM Deployment Target Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/platform-support.md Ensure the `platforms` declaration in your `Package.swift` file specifies the minimum deployment version for each platform to resolve SPM issues. ```swift platforms: [.iOS(.v12), .macOS(.v10_11)] ``` -------------------------------- ### Verify Network Connectivity to Binary Repository Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Check if you can reach the remote repository hosting the binary frameworks. This helps diagnose network-related download failures. ```bash curl -I https://raw.githubusercontent.com/stasel/WebRTC/latest/WebRTC.json ``` -------------------------------- ### Correct and Incorrect Cartfile Syntax Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Ensure your Cartfile uses the correct 'binary' keyword for specifying remote binary frameworks. Incorrect syntax can lead to build failures. ```shell # ✅ Correct binary "https://raw.githubusercontent.com/stasel/WebRTC/latest/WebRTC.json" ``` ```shell # ❌ Incorrect (missing binary keyword) "https://raw.githubusercontent.com/stasel/WebRTC/latest/WebRTC.json" ``` -------------------------------- ### Objective-C: Import WebRTC and Initialize Factory (CocoaPods) Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/installation-guide.md Import the WebRTC header file and initialize the RTCPeerConnectionFactory within your Objective-C class when using CocoaPods. ```objectivec #import @interface VideoCallViewController : UIViewController @end @implementation VideoCallViewController - (void)setupRTC { RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init]; } @end ``` -------------------------------- ### List Available WebRTC Releases via GitHub API Source: https://github.com/stasel/webrtc/blob/latest/_autodocs/troubleshooting.md Query the GitHub API to retrieve a list of all available release tag names for the WebRTC repository. This is useful for verifying version existence. ```bash curl -s https://api.github.com/repos/stasel/WebRTC/releases | jq '.[].tag_name' ``` -------------------------------- ### Add Swift Package Manager Dependency (Latest Branch) Source: https://github.com/stasel/webrtc/blob/latest/README.md Use this to add the WebRTC package from the 'latest' branch for the most up-to-date binary. ```swift dependencies: [ .package(url: "https://github.com/stasel/WebRTC.git", branch: "latest") ] ```