{"id":29835227,"url":"https://github.com/livekit/client-sdk-swift","last_synced_at":"2025-07-29T12:17:34.315Z","repository":{"id":37434831,"uuid":"311453102","full_name":"livekit/client-sdk-swift","owner":"livekit","description":"LiveKit Swift Client SDK. Easily build live audio or video experiences on iOS, macOS, tvOS, and visionOS.","archived":false,"fork":false,"pushed_at":"2025-07-23T03:02:30.000Z","size":5624,"stargazers_count":303,"open_issues_count":62,"forks_count":138,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-07-23T04:21:28.668Z","etag":null,"topics":["ios","macos","swift","tvos","video","visionos","webrtc"],"latest_commit_sha":null,"homepage":"https://livekit.io","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livekit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-09T20:11:24.000Z","updated_at":"2025-07-23T02:35:49.000Z","dependencies_parsed_at":"2023-09-22T02:56:22.372Z","dependency_job_id":"edbb3aed-9acd-4a8a-b44a-c2924bc9b1c7","html_url":"https://github.com/livekit/client-sdk-swift","commit_stats":{"total_commits":768,"total_committers":11,"mean_commits":69.81818181818181,"dds":"0.14192708333333337","last_synced_commit":"70d3f510f8d0b34006b5556d721805792b9692bf"},"previous_names":[],"tags_count":87,"template":false,"template_full_name":null,"purl":"pkg:github/livekit/client-sdk-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fclient-sdk-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fclient-sdk-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fclient-sdk-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fclient-sdk-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livekit","download_url":"https://codeload.github.com/livekit/client-sdk-swift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fclient-sdk-swift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267685555,"owners_count":24127706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","macos","swift","tvos","video","visionos","webrtc"],"created_at":"2025-07-29T12:17:33.711Z","updated_at":"2025-07-29T12:17:34.296Z","avatar_url":"https://github.com/livekit.png","language":"Swift","readme":"\u003c!--BEGIN_BANNER_IMAGE--\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/.github/banner_dark.png\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"/.github/banner_light.png\"\u003e\n  \u003cimg style=\"width:100%;\" alt=\"The LiveKit icon, the name of the repository and some sample code in the background.\" src=\"https://raw.githubusercontent.com/livekit/client-sdk-swift/main/.github/banner_light.png\"\u003e\n\u003c/picture\u003e\n\n\u003c!--END_BANNER_IMAGE--\u003e\n\n# iOS/macOS Swift SDK for LiveKit\n\n\u003c!--BEGIN_DESCRIPTION--\u003e\nUse this SDK to add realtime video, audio and data features to your Swift app. By connecting to \u003ca href=\"https://livekit.io/\"\u003eLiveKit\u003c/a\u003e Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code.\n\u003c!--END_DESCRIPTION--\u003e\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flivekit%2Fclient-sdk-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/livekit/client-sdk-swift)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flivekit%2Fclient-sdk-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/livekit/client-sdk-swift)\n\n## Docs \u0026 Example app\n\n\u003e [!NOTE]\n\u003e Version 2 of the Swift SDK contains breaking changes from Version 1.\n\u003e Read the [migration guide](https://docs.livekit.io/guides/migrate-from-v1/) for a detailed overview of what has changed.\n\nDocs and guides are at [https://docs.livekit.io](https://docs.livekit.io).\n\nThere is full source code of a [iOS/macOS Swift UI Example App](https://github.com/livekit/client-example-swift).\n\nFor minimal examples view this repo 👉 [Swift SDK Examples](https://github.com/livekit/client-example-collection-swift)\n\n## Installation\n\nLiveKit for Swift is available as a Swift Package.\n\n### Package.swift\n\nAdd the dependency and also to your target\n\n```swift title=\"Package.swift\"\nlet package = Package(\n  ...\n  dependencies: [\n    .package(name: \"LiveKit\", url: \"https://github.com/livekit/client-sdk-swift.git\", .upToNextMajor(\"2.6.1\")),\n  ],\n  targets: [\n    .target(\n      name: \"MyApp\",\n      dependencies: [\"LiveKit\"]\n    )\n  ]\n}\n```\n\n### XCode\n\nGo to Project Settings -\u003e Swift Packages.\n\nAdd a new package and enter: `https://github.com/livekit/client-sdk-swift`\n\n### CocoaPods\n\nFor installation using CocoaPods, please refer to this [guide](./Docs/cocoapods.md).\n\n## iOS Usage\n\nLiveKit provides an UIKit based `VideoView` class that renders video tracks. Subscribed audio tracks are automatically played.\n\n```swift\nimport LiveKit\nimport UIKit\n\nclass RoomViewController: UIViewController {\n\n    lazy var room = Room(delegate: self)\n\n    lazy var remoteVideoView: VideoView = {\n        let videoView = VideoView()\n        view.addSubview(videoView)\n        // Additional initialization ...\n        return videoView\n    }()\n\n    lazy var localVideoView: VideoView = {\n        let videoView = VideoView()\n        view.addSubview(videoView)\n        // Additional initialization ...\n        return videoView\n    }()\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        view.backgroundColor = .white\n\n        let url = \"ws://your_host\"\n        let token = \"your_jwt_token\"\n\n        Task {\n            do {\n                try await room.connect(url: url, token: token)\n                // Connection successful...\n\n                // Publishing camera \u0026 mic...\n                try await room.localParticipant.setCamera(enabled: true)\n                try await room.localParticipant.setMicrophone(enabled: true)\n            } catch {\n                // Failed to connect\n            }\n        }\n    }\n}\n\nextension RoomViewController: RoomDelegate {\n\n    func room(_: Room, participant _: LocalParticipant, didPublishTrack publication: LocalTrackPublication) {\n        guard let track = publication.track as? VideoTrack else { return }\n        DispatchQueue.main.async {\n            self.localVideoView.track = track\n        }\n    }\n\n    func room(_: Room, participant _: RemoteParticipant, didSubscribeTrack publication: RemoteTrackPublication) {\n        guard let track = publication.track as? VideoTrack else { return }\n        DispatchQueue.main.async {\n            self.remoteVideoView.track = track\n        }\n    }\n}\n```\n\n### Screen Sharing\n\nSee [iOS Screen Sharing instructions](Docs/ios-screen-sharing.md).\n\n## Integration Notes\n\n### Thread safety\n\nSince `VideoView` is a UI component, all operations (read/write properties etc) must be performed from the `main` thread.\n\nOther core classes can be accessed from any thread.\n\nDelegates will be called on the SDK's internal thread.\nMake sure any access to your app's UI elements are from the main thread, for example by using `@MainActor` or `DispatchQueue.main.async`.\n\n### Swift 6\n\nLiveKit is currently 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.\n\n### Memory management\n\nIt is recommended to use **weak var** when storing references to objects created and managed by the SDK, such as `Participant`, `TrackPublication` etc. These objects are invalid when the `Room` disconnects, and will be released by the SDK. Holding strong reference to these objects will prevent releasing `Room` and other internal objects.\n\n`VideoView.track` property does not hold strong reference, so it's not required to set it to `nil`.\n\n### AudioSession management\n\nLiveKit will automatically manage the underlying `AVAudioSession` while connected. The session will be set to `playback` category by default. When a local stream is published, it'll be switched to\n`playAndRecord`. In general, it'll pick sane defaults and do the right thing.\n\nHowever, if you'd like to customize this behavior, you would override `AudioManager.customConfigureAudioSessionFunc` to manage the underlying session on your own. See [example here](https://github.com/livekit/client-sdk-swift/blob/1f5959f787805a4b364f228ccfb413c1c4944748/Sources/LiveKit/Track/AudioManager.swift#L153) for the default behavior.\n\nFor more audio related information see the [Audio guide](./Docs/audio.md).\n\n### Integration with CallKit\n\nTo integrate with CallKit for background-triggered incoming calls, LiveKit's audio session must be synchronized with CallKit's audio session:\n\n1. Add `import LiveKitWebRTC` to your CallProvider file.\n2. In your `CXProviderDelegate` implementation, add the following:\n\n```swift\nfunc provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession){\n    LKRTCAudioSession.sharedInstance().audioSessionDidActivate(audioSession)\n    // ...\n}\nfunc provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {\n    LKRTCAudioSession.sharedInstance().audioSessionDidDeactivate(audioSession)\n    // ...\n}\n```\n\nYou would also want to turn off automatic `AVAudioSession` configuration.\n\n```swift\nAudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false\n```\n\nFor more audio related information see the [Audio guide](./Docs/audio.md).\n\n### iOS Simulator limitations\n\n- Publishing the camera track is not supported by iOS Simulator.\n\n### ScrollView performance\n\nIt is recommended to turn off rendering of `VideoView`s that scroll off the screen and isn't visible by setting `false` to `isEnabled` property and `true` when it will re-appear to save CPU resources.\n\n`UICollectionViewDelegate`'s `willDisplay` / `didEndDisplaying` has been reported to be unreliable for this purpose. Specifically, in some iOS versions `didEndDisplaying` could get invoked even when the cell is visible.\n\nThe following is an alternative method to using `willDisplay` / `didEndDisplaying` :\n\n```swift\n// 1. define a weak-reference set for all cells\nprivate var allCells = NSHashTable\u003cParticipantCell\u003e.weakObjects()\n```\n\n```swift\n// in UICollectionViewDataSource...\npublic func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n\n    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ParticipantCell.reuseIdentifier, for: indexPath)\n\n    if let cell = cell as? ParticipantCell {\n        // 2. keep weak reference to the cell\n        allCells.add(cell)\n\n        // configure cell etc...\n    }\n\n    return cell\n}\n```\n\n```swift\n// 3. define a func to re-compute and update isEnabled property for cells that visibility changed\nfunc reComputeVideoViewEnabled() {\n\n    let visibleCells = collectionView.visibleCells.compactMap { $0 as? ParticipantCell }\n    let offScreenCells = allCells.allObjects.filter { !visibleCells.contains($0) }\n\n    for cell in visibleCells.filter({ !$0.videoView.isEnabled }) {\n        print(\"enabling cell#\\(cell.hashValue)\")\n        cell.videoView.isEnabled = true\n    }\n\n    for cell in offScreenCells.filter({ $0.videoView.isEnabled }) {\n        print(\"disabling cell#\\(cell.hashValue)\")\n        cell.videoView.isEnabled = false\n    }\n}\n```\n\n```swift\n// 4. set a timer to invoke the func\nself.timer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true, block: { [weak self] _ in\n    self?.reComputeVideoViewEnabled()\n})\n\n// alternatively, you can call `reComputeVideoViewEnabled` whenever cell visibility changes (such as scrollViewDidScroll(_:)),\n// but this will be harder to track all cases such as cell reload etc.\n```\n\nFor the full example, see 👉 [UIKit Minimal Example](https://github.com/livekit/client-example-collection-swift/tree/main/uikit-minimal)\n\n# Frequently asked questions\n\n### How to publish camera in 60 FPS ?\n\n- Create a `LocalVideoTrack` by calling `LocalVideoTrack.createCameraTrack(options: CameraCaptureOptions(fps: 60))`.\n- Publish with `LocalParticipant.publish(videoTrack: track, publishOptions: VideoPublishOptions(encoding: VideoEncoding(maxFps: 60)))`.\n\n# Known issues\n\n### Avoid crashes on macOS Catalina\n\nIf your app is targeting macOS Catalina, make sure to do the following to avoid crash (ReplayKit not found):\n\n1. Explicitly add \"ReplayKit.framework\" to the Build Phases \u003e Link Binary with Libraries section\n2. Set it to Optional\n\n\u003cimg width=\"752\" alt=\"replykit\" src=\"https://user-images.githubusercontent.com/548776/201249295-51d9cb76-32bd-4b10-9f4c-02951d1b2edb.png\"\u003e\n\n- I am not sure why this is required for ReplayKit at the moment.\n- If you are targeting macOS 11.0+, this is not required.\n\n# Getting help / Contributing\n\nPlease join us on [Slack](https://livekit.io/join-slack) to get help from our devs / community members. We welcome your contributions(PRs) and details can be discussed there.\n\n\u003c!--BEGIN_REPO_NAV--\u003e\n\u003cbr/\u003e\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth colspan=\"2\"\u003eLiveKit Ecosystem\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003eLiveKit SDKs\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/client-sdk-js\"\u003eBrowser\u003c/a\u003e · \u003cb\u003eiOS/macOS/visionOS\u003c/b\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-android\"\u003eAndroid\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-flutter\"\u003eFlutter\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-react-native\"\u003eReact Native\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/rust-sdks\"\u003eRust\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/node-sdks\"\u003eNode.js\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/python-sdks\"\u003ePython\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-unity\"\u003eUnity\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-unity-web\"\u003eUnity (WebGL)\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-esp32\"\u003eESP32\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eServer APIs\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/node-sdks\"\u003eNode.js\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/server-sdk-go\"\u003eGolang\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/server-sdk-ruby\"\u003eRuby\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/server-sdk-kotlin\"\u003eJava/Kotlin\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/python-sdks\"\u003ePython\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/rust-sdks\"\u003eRust\u003c/a\u003e · \u003ca href=\"https://github.com/agence104/livekit-server-sdk-php\"\u003ePHP (community)\u003c/a\u003e · \u003ca href=\"https://github.com/pabloFuente/livekit-server-sdk-dotnet\"\u003e.NET (community)\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eUI Components\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/components-js\"\u003eReact\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/components-android\"\u003eAndroid Compose\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/components-swift\"\u003eSwiftUI\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/components-flutter\"\u003eFlutter\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eAgents Frameworks\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/agents\"\u003ePython\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/agents-js\"\u003eNode.js\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/agent-playground\"\u003ePlayground\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eServices\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/livekit\"\u003eLiveKit server\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/egress\"\u003eEgress\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/ingress\"\u003eIngress\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/sip\"\u003eSIP\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eResources\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://docs.livekit.io\"\u003eDocs\u003c/a\u003e · \u003ca href=\"https://github.com/livekit-examples\"\u003eExample apps\u003c/a\u003e · \u003ca href=\"https://livekit.io/cloud\"\u003eCloud\u003c/a\u003e · \u003ca href=\"https://docs.livekit.io/home/self-hosting/deployment\"\u003eSelf-hosting\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/livekit-cli\"\u003eCLI\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c!--END_REPO_NAV--\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivekit%2Fclient-sdk-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivekit%2Fclient-sdk-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivekit%2Fclient-sdk-swift/lists"}