Real-time iOS Screen Broadcasting Client for Clash Royale Coaching
CRScreenClient is a SwiftUI-based iOS application that enables real-time screen sharing and broadcasting for Clash Royale gameplay analysis. It connects to the CRCoach server ecosystem to provide seamless coaching experiences.
CRScreenClient transforms your iOS device into a powerful broadcasting tool for Clash Royale coaching sessions. Players can broadcast their gameplay in real-time while coaches connect via the web interface to provide live feedback and analysis.
- ๐ด Real-time Screen Broadcasting - Stream your Clash Royale gameplay with minimal latency
- ๐ฑ ReplayKit Integration - Native iOS screen recording with broadcast extensions
- ๐ WebRTC Streaming - Low-latency peer-to-peer video streaming
- ๐ฎ 4-Digit Session Codes - Simple connection system for coach-player sessions
- โ๏ธ Quality Controls - Adjustable streaming quality (Low/Medium/High)
- ๐ Performance Monitoring - Real-time stats and connection diagnostics
- ๐พ Local Recording - Automatic session recording with playback
- ๐ง Debug Tools - Comprehensive debugging and server configuration options
CRScreenClient/
โโโ App/ # App entry point
โ โโโ CRScreenClientApp.swift # Main app configuration
โโโ Core/ # Core functionality
โ โโโ Constants/ # App constants and configuration
โ โโโ Extensions/ # Swift extensions (Color, etc.)
โ โโโ Debug/ # Debug settings and tools
โ โโโ WebRTC/ # WebRTC client implementation
โโโ Features/ # Feature modules
โ โโโ Broadcasting/ # Broadcasting logic
โ โ โโโ Models/ # BroadcastManager, StorageManager
โ โโโ UI/ # User interface
โ โโโ Components/ # Reusable UI components
โ โโโ Screens/ # Main app screens
โโโ CRScreenClientBroadcast/ # Broadcast extension
โโโ SampleHandler.swift # ReplayKit broadcast handler
- Session Creation: App generates a 4-digit session code
- Broadcast Start: User initiates ReplayKit broadcast
- WebRTC Setup: Extension establishes WebRTC connection to server
- Coach Connection: Coach connects via web interface using session code
- Real-time Streaming: Video frames stream with low latency
- Local Recording: Sessions automatically recorded for later review
- Framework: SwiftUI + Combine
- Broadcasting: ReplayKit + Broadcast Extension
- Video Streaming: WebRTC (iOS)
- Storage: UserDefaults + File System
- Networking: URLSession WebSocket
- WebRTC: Real-time video streaming
- ReplayKit: iOS screen recording
- AVFoundation: Video processing
- Combine: Reactive programming
- WebRTC Signaling: WebSocket connection to CRCoach server
- Session Management: 4-digit code system
- Quality Adaptation: Dynamic bitrate and resolution adjustment
- iOS 14.0+
- Xcode 13.0+
- Active Apple Developer Account (for ReplayKit)
- CRCoach server running (see CRCoach Repository)
-
Clone the repository
git clone https://github.com/yourusername/CRScreenClient.git cd CRScreenClient -
Open in Xcode
open CRScreenClient.xcodeproj
-
Configure Bundle IDs
- Update bundle identifiers in project settings
- Ensure broadcast extension ID matches:
com.elmelz.CRScreenClient.Broadcast
-
Set App Group
- Configure App Group:
group.com.elmelz.crcoach - Enable App Groups capability for both app and extension
- Configure App Group:
-
Build and Run
- Select your device
- Build and install both app and broadcast extension
The app connects to CRCoach server for WebRTC signaling:
// Default server configuration
static let webRTCSignalingServer = "ws://35.208.133.112:8080/ws"
static let defaultBroadcastServer = "http://35.208.133.112:8080/"Access debug menu (triple-tap) to configure custom server:
- Custom URL: Set your server endpoint
- Secure Connection: Enable HTTPS/WSS
- Custom Port: Override default port
- Launch App: Open CRScreenClient
- Session Code: Note the 4-digit code displayed
- Start Broadcast: Tap broadcast button
- Select Extension: Choose "CRScreenClient Broadcast"
- Begin Streaming: Tap "Start Broadcast"
Adjust streaming quality based on connection:
-
๐ต Low Quality
- Bitrate: 400 kbps
- Resolution: 40% scale
- Framerate: 12 fps
- Best for: Slow connections
-
๐ก Medium Quality (Default)
- Bitrate: 800 kbps
- Resolution: 70% scale
- Framerate: 20 fps
- Best for: Balanced performance
-
๐ฃ High Quality
- Bitrate: 1200 kbps
- Resolution: 85% scale
- Framerate: 24 fps
- Best for: Fast connections
- Recent Broadcasts: View and replay past sessions
- Local Recordings: Access recorded gameplay
- Connection Stats: Monitor streaming performance
- Debug Info: Detailed technical diagnostics
Key configuration options:
enum URLs {
static let webRTCSignalingServer = "ws://your-server:8080/ws"
static let defaultBroadcastServer = "http://your-server:8080/"
static let webApp = "royaltrainer.com"
}
enum Broadcast {
static let extensionID = "com.yourteam.CRScreenClient.Broadcast"
static let groupID = "group.com.yourteam.crcoach"
}
enum WebRTC {
static let maxReconnectAttempts = 3
static let connectionTimeout: TimeInterval = 8.0
}enum FeatureFlags {
static let enableDebugLogging = true
static let enablePerformanceMonitoring = true
static let enableLocalRecording = true
}Triple-tap anywhere on the main screen to access debug tools:
- Server Configuration: Custom server settings
- Connection Diagnostics: WebRTC connection details
- Performance Metrics: CPU, memory, and network stats
- Watermark Controls: Anti-piracy watermark management
- Quality Override: Manual quality parameter adjustment
Enable detailed logging:
Constants.FeatureFlags.enableDebugLogging = trueView logs in Xcode console or device logs.
- Session Registration: App registers 4-digit codes with server
- WebRTC Signaling: Establishes peer connections via server
- Status Updates: Real-time broadcast state synchronization
- Recording Upload: Optional server-side session storage
CRScreenClient works seamlessly with the web-based coaching interface:
- Coach Dashboard: Real-time session monitoring
- Multi-viewer Support: Multiple coaches per session
- Inference Integration: AI-powered gameplay analysis
- Session Recording: Server-side session archival
GET /health- Server health checkWS /ws/{session_code}- WebRTC signalingPOST /upload/- Recording uploadGET /session/{code}/status- Session status
The app automatically adjusts streaming parameters based on:
- Device Performance: CPU and memory usage
- Network Conditions: Bandwidth and latency
- Frame Processing: Real-time frame analysis
- Dynamic Frame Skipping: Maintains smooth performance
- Adaptive Bitrate: Adjusts to network conditions
- Smart Compression: Optimized video encoding
- Background Processing: Efficient resource management
-
Prerequisites
# Xcode 13.0+ # iOS 14.0+ deployment target # Apple Developer Account
-
Configuration
# Update bundle IDs in project settings # Configure App Groups capability # Set broadcast extension bundle ID
-
Dependencies
- No external package managers required
- All dependencies included in project
โโโ CRScreenClient.xcodeproj # Xcode project
โโโ CRScreenClient/ # Main app target
โโโ CRScreenClientBroadcast/ # Broadcast extension
โโโ CRShared.swift # Shared code
โโโ README.md # This file
CRScreenClientApp.swift: App entry point and configurationMainScreen.swift: Primary user interfaceBroadcastManager.swift: Session and broadcasting logicWebRTCManager.swift: WebRTC client implementationSampleHandler.swift: ReplayKit broadcast extensionConstants.swift: App configuration and endpoints
- iOS Version: 14.0 or later
- Device: iPhone or iPad
- Storage: 50MB minimum
- Network: Wi-Fi or cellular data
- CRCoach Server: Running WebRTC signaling service
- Port Access: 8080 (default) or custom configured
- Protocol: WebSocket (WS/WSS) support
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
- Follow Swift style guidelines
- Add appropriate logging for debugging
- Test on multiple iOS versions
- Ensure ReplayKit extension compatibility
- Maintain WebRTC connection stability
This project is part of the CRCoach ecosystem. See the LICENSE file for details.
Broadcast Not Starting
- Check App Groups configuration
- Verify bundle IDs match
- Ensure ReplayKit permissions
Connection Failed
- Verify server is running
- Check network connectivity
- Review WebRTC signaling logs
Poor Video Quality
- Adjust quality settings
- Check network bandwidth
- Monitor device performance
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Server Issues: CRCoach Repository
- Initial release
- ReplayKit broadcasting
- WebRTC streaming
- 4-digit session codes
- Quality controls
- Local recording
- Debug tools
CRScreenClient - Empowering Clash Royale coaching through real-time screen sharing ๐