Version 2 of the Swift SDK contains breaking changes from Version 1. This guide will help you migrate your existing application to the latest version.
Overview
The Swift SDK v2 represents a major architectural update with improved performance, better Swift 6 concurrency support, and enhanced API design. While there are breaking changes, most applications can be migrated with straightforward updates.What’s Changed
Version 2 introduces several significant improvements:Swift Concurrency
The SDK is now compiled using Swift 6.0 with full support for strict concurrency. Apps compiled in Swift 6 language mode will not need to use@preconcurrency or @unchecked Sendable to access LiveKit classes.
Thread Safety
All core classes can be accessed from any thread (exceptVideoView, which must be used from the main thread). Delegates will be called on the SDK’s internal thread, so make sure any access to UI elements uses @MainActor or DispatchQueue.main.async.
Memory Management
It is now recommended to use weak var when storing references to SDK-managed objects:Room disconnects and will be released by the SDK. Holding strong references will prevent releasing Room and other internal objects.
API Changes
Connection & Room
The basic connection API remains similar:AudioSession Management
Audio session handling has been updated. LiveKit automatically managesAVAudioSession while connected, defaulting to .playback category and switching to .playAndRecord when publishing.
To configure manually:
CallKit Integration
CallKit integration now requires explicit audio engine availability control:VideoView
TheVideoView API remains largely unchanged, but remember that all operations must be performed from the main thread:
Migration Checklist
Update Delegate Implementations
Ensure all UI updates in delegate methods are dispatched to the main thread:
Review AudioSession Configuration
If you’re using custom audio session configuration or CallKit, update to use the new audio engine availability API.
Additional Resources
Getting Help
If you encounter issues during migration:- Join our Slack community
- Review the FAQ
- Check Troubleshooting
- Submit issues on GitHub