Documentation Index Fetch the complete documentation index at: https://mintlify.com/livekit/client-sdk-swift/llms.txt
Use this file to discover all available pages before exploring further.
The LiveKit Swift SDK provides support for tvOS applications, enabling video conferencing and streaming experiences on Apple TV.
Minimum version: tvOS 17.0+
tvOS support was added in SDK version 2.x with tvOS 17 as the minimum version.
Capabilities
tvOS is primarily designed for receiving and displaying video/audio streams, with limited capture capabilities.
Supported Features
✅ Connect to LiveKit rooms
✅ Receive and render video tracks
✅ Receive and play audio tracks
✅ Data channels (send/receive)
✅ Room events and participant management
✅ VideoView rendering
✅ SwiftUI components
Limited Features
⚠️ Camera capture : tvOS devices don’t have built-in cameras
⚠️ Microphone capture : Limited hardware support
⚠️ Screen sharing : Not applicable for tvOS
VideoView
The SDK provides a UIView-based VideoView for rendering video tracks on tvOS:
import LiveKit
import UIKit
class RoomViewController : UIViewController {
lazy var videoView: VideoView = {
let videoView = VideoView ()
view. addSubview (videoView)
videoView. layoutMode = . fill
return videoView
}()
override func viewDidLoad () {
super . viewDidLoad ()
Task {
try await connectToRoom ()
}
}
func connectToRoom () async throws {
let room = Room ( delegate : self )
try await room. connect ( url : url, token : token)
}
}
extension RoomViewController : RoomDelegate {
func room ( _ : Room, participant : RemoteParticipant, didSubscribeTrack publication : RemoteTrackPublication) {
guard let track = publication.track as? VideoTrack else { return }
DispatchQueue. main . async {
self . videoView . track = track
}
}
}
Video Rendering
tvOS supports both rendering modes:
Metal Rendering (default): Hardware-accelerated rendering
AVSampleBuffer Rendering : Alternative rendering mode
videoView. renderMode = . metal // or .sampleBuffer
Layout Options
// Control how video fits within the view
videoView. layoutMode = . fill // .fill or .fit
// Mirror video if needed
videoView. mirrorMode = . auto // .auto, .mirror, or .off
Camera Support
tvOS devices do not have built-in cameras. However, you can use external cameras on supported tvOS versions:
External Camera (tvOS 17+)
import AVFoundation
// Check for available cameras
let devices = try await CameraCapturer. captureDevices ()
if ! devices. isEmpty {
// External camera is available
let options = CameraCaptureOptions (
dimensions : . h720_169 ,
fps : 30
)
try await room. localParticipant . setCamera (
enabled : true ,
captureOptions : options
)
} else {
print ( "No camera devices available on tvOS" )
}
Multitasking Camera Access (tvOS 17+)
Similar to iOS 16+, tvOS 17+ supports multitasking camera access:
if let cameraCapturer = cameraTrack ? .capturer as? CameraCapturer {
if cameraCapturer.isMultitaskingAccessSupported {
cameraCapturer. isMultitaskingAccessEnabled = true
}
}
See CameraCapturer.swift:52 for implementation details.
Audio Support
Receiving Audio
Receiving and playing audio works normally on tvOS:
// Audio tracks are automatically played when subscribed
func room ( _ : Room, participant : RemoteParticipant, didSubscribeTrack publication : RemoteTrackPublication) {
if publication.kind == .audio {
print ( "Subscribed to audio track: \( publication. sid ) " )
// Audio will play automatically
}
}
Audio Session (tvOS)
tvOS uses AVAudioSession similar to iOS:
import AVFoundation
// Audio session is automatically managed by the SDK
// For manual control:
AudioManager. shared . audioSession . isAutomaticConfigurationEnabled = false
// Configure manually
let session = AVAudioSession. sharedInstance ()
try session. setCategory (. playback , mode : . default )
try session. setActive ( true )
See AudioSessionConfiguration.swift:17 for available configurations.
Microphone Capture
tvOS devices typically don’t have built-in microphones. External microphones may work if supported by the hardware.
// Attempt to enable microphone (may fail if no hardware available)
do {
try await room. localParticipant . setMicrophone ( enabled : true )
} catch {
print ( "Microphone not available: \( error ) " )
}
Data Channels
Data channels work fully on tvOS for sending and receiving custom data:
// Send data to all participants
try await room. localParticipant . publish ( data : data, options : DataPublishOptions (
reliable : true
))
// Receive data
func room ( _ : Room, participant : RemoteParticipant, didReceiveData data : Data, forTopic topic : String ) {
print ( "Received data from \( participant. identity ) : \( data. count ) bytes" )
}
Permissions
tvOS requires permissions for camera and microphone if external devices are used.
Info.plist Entries
Add these keys to your Info.plist:
< key > NSCameraUsageDescription </ key >
< string > This app needs camera access for video calls </ string >
< key > NSMicrophoneUsageDescription </ key >
< string > This app needs microphone access for audio calls </ string >
SwiftUI Integration
The SDK provides SwiftUI components for tvOS:
import SwiftUI
import LiveKit
struct VideoCallView : View {
@StateObject var room = Room ()
var body: some View {
ZStack {
Color. black . ignoresSafeArea ()
if let videoTrack = room.remoteParticipants. first ? .videoTracks. first ? .track {
SwiftUIVideoView (videoTrack)
. aspectRatio ( 16 / 9 , contentMode : . fit )
} else {
Text ( "Waiting for video..." )
. foregroundColor (. white )
}
}
. onAppear {
Task {
try await room. connect ( url : url, token : token)
}
}
}
}
Focus and Navigation
tvOS uses focus-based navigation with the Siri Remote. Consider this when designing your UI:
import UIKit
class ParticipantCell : UICollectionViewCell {
let videoView = VideoView ()
override var canBecomeFocused: Bool {
return true
}
override func didUpdateFocus ( in context : UIFocusUpdateContext, with coordinator : UIFocusAnimationCoordinator) {
super . didUpdateFocus ( in : context, with : coordinator)
coordinator. addCoordinatedAnimations ({
if self .isFocused {
self . transform = CGAffineTransform ( scaleX : 1.1 , y : 1.1 )
} else {
self . transform = . identity
}
}, completion : nil )
}
}
Limitations
Hardware Limitations
No built-in camera : tvOS devices don’t have cameras
No built-in microphone : Most Apple TV models lack microphones
No screen capture : Not applicable for tvOS
API Limitations
Some iOS-specific APIs are not available on tvOS:
Screen sharing (no ReplayKit broadcast extension)
Pinch-to-zoom gestures (different input method)
CallKit integration (not applicable)
Apple TV hardware varies by generation:
Apple TV 4K (2nd/3rd gen): Full hardware acceleration
Older models: May have limited performance with multiple video streams
Building and Testing
# Build for tvOS Simulator
xcodebuild build -scheme LiveKit -destination 'platform=tvOS Simulator'
# Run tests
xcodebuild test -scheme LiveKit -only-testing LiveKitCoreTests -destination 'platform=tvOS Simulator'
# List available simulators
xcrun simctl list devices tvOS
Use Cases
tvOS is well-suited for:
Video viewing : Watch live streams or recordings
Digital signage : Display video feeds in public spaces
Monitoring : View security cameras or dashboards
Telehealth : Display remote participants on TV
Education : Classroom displays for remote learning
Thread Safety
VideoView must be accessed from the main thread on tvOS.
// Correct: Update VideoView on main thread
DispatchQueue. main . async {
videoView. track = track
}
// Or use MainActor
Task { @MainActor in
videoView. track = track
}
Example Projects
Next Steps
Core Concepts Learn about Room and Participant management
iOS Platform Compare with full iOS capabilities