Skip to content

Commit 00a164e

Browse files
authored
Xcode 26 beta build errors (Swift 6.2) (#717)
Resolves #716 Fixes new build errors mostly related to: - `static` properties validated more aggressively for `Sendable` conformance - local flags in audio conversion - awkward access to `BundleInfo` - property wrappers cannot be `nonisolated(unsafe)` - `actor` workaround shouldn't be necessary after removing that Also, unifies concurrency-related `#if`-ology.
1 parent 812f148 commit 00a164e

File tree

9 files changed

+30
-47
lines changed

9 files changed

+30
-47
lines changed

.changes/xcode-26

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patch type="fixed" "Fixed Xcode 26 build errors with Swift 6.2"

Sources/LiveKit/Audio/Manager/AudioManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal import LiveKitWebRTC
2828
public class AudioManager: Loggable {
2929
// MARK: - Public
3030

31-
#if compiler(>=6.0)
31+
#if swift(>=6.0)
3232
public nonisolated(unsafe) static let shared = AudioManager()
3333
#else
3434
public static let shared = AudioManager()

Sources/LiveKit/Broadcast/BroadcastBundleInfo.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import Foundation
2020

21-
actor BroadcastBundleInfo {
21+
enum BroadcastBundleInfo {
2222
/// Identifier of the app group shared by the primary app and broadcast extension.
2323
static var groupIdentifier: String? {
2424
if let override = groupIdentifierOverride { return override }
@@ -45,11 +45,13 @@ actor BroadcastBundleInfo {
4545
socketPath != nil && screenSharingExtension != nil
4646
}
4747

48-
@BundleInfo("RTCAppGroupIdentifier")
49-
private static var groupIdentifierOverride: String?
48+
private static var groupIdentifierOverride: String? {
49+
Bundle.main.infoDictionary?["RTCAppGroupIdentifier"] as? String
50+
}
5051

51-
@BundleInfo("RTCScreenSharingExtension")
52-
private static var screenSharingExtensionOverride: String?
52+
private static var screenSharingExtensionOverride: String? {
53+
Bundle.main.infoDictionary?["RTCScreenSharingExtension"] as? String
54+
}
5355

5456
private static let extensionSuffix = "broadcast"
5557
private static let socketFileDescriptor = "rtc_SSFD"

Sources/LiveKit/Broadcast/Support/BundleInfo.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

Sources/LiveKit/Core/RTC.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ private extension Array where Element: LKRTCVideoCodecInfo {
3131
}
3232
}
3333

34-
private class VideoEncoderFactory: LKRTCDefaultVideoEncoderFactory {
34+
private class VideoEncoderFactory: LKRTCDefaultVideoEncoderFactory, @unchecked Sendable {
3535
override func supportedCodecs() -> [LKRTCVideoCodecInfo] {
3636
super.supportedCodecs().rewriteCodecsIfNeeded()
3737
}
3838
}
3939

40-
private class VideoDecoderFactory: LKRTCDefaultVideoDecoderFactory {
40+
private class VideoDecoderFactory: LKRTCDefaultVideoDecoderFactory, @unchecked Sendable {
4141
override func supportedCodecs() -> [LKRTCVideoCodecInfo] {
4242
super.supportedCodecs().rewriteCodecsIfNeeded()
4343
}
4444
}
4545

46-
private class VideoEncoderFactorySimulcast: LKRTCVideoEncoderFactorySimulcast {
46+
private class VideoEncoderFactorySimulcast: LKRTCVideoEncoderFactorySimulcast, @unchecked Sendable {
4747
override func supportedCodecs() -> [LKRTCVideoCodecInfo] {
4848
super.supportedCodecs().rewriteCodecsIfNeeded()
4949
}
@@ -74,14 +74,14 @@ actor RTC {
7474

7575
// global properties are already lazy
7676

77-
private static let encoderFactory: LKRTCVideoEncoderFactory = {
77+
private static let encoderFactory: LKRTCVideoEncoderFactory & Sendable = {
7878
let encoderFactory = VideoEncoderFactory()
7979
return VideoEncoderFactorySimulcast(primary: encoderFactory,
8080
fallback: encoderFactory)
8181

8282
}()
8383

84-
private static let decoderFactory = VideoDecoderFactory()
84+
private static let decoderFactory: LKRTCVideoDecoderFactory & Sendable = VideoDecoderFactory()
8585

8686
static let audioProcessingModule: LKRTCDefaultAudioProcessingModule = .init()
8787

Sources/LiveKit/Extensions/AVAudioPCMBuffer.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import Accelerate
18-
import AVFoundation
18+
@preconcurrency import AVFoundation
1919

2020
public extension AVAudioPCMBuffer {
2121
func resample(toSampleRate targetSampleRate: Double) -> AVAudioPCMBuffer? {
@@ -48,7 +48,12 @@ public extension AVAudioPCMBuffer {
4848
return nil
4949
}
5050

51+
#if swift(>=6.0)
52+
// Won't be accessed concurrently, marking as nonisolated(unsafe) to avoid Atomics.
53+
nonisolated(unsafe) var isDone = false
54+
#else
5155
var isDone = false
56+
#endif
5257
let inputBlock: AVAudioConverterInputBlock = { _, outStatus in
5358
if isDone {
5459
outStatus.pointee = .noDataNow

Sources/LiveKit/Extensions/Sendable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ extension LKRTCSessionDescription: @unchecked Swift.Sendable {}
4141
extension LKRTCStatisticsReport: @unchecked Swift.Sendable {}
4242
extension LKRTCVideoCodecInfo: @unchecked Swift.Sendable {}
4343
extension LKRTCVideoFrame: @unchecked Swift.Sendable {}
44+
extension LKRTCRtpCapabilities: @unchecked Swift.Sendable {}
4445

4546
// MARK: Mutable classes - to be validated
4647

4748
extension LKRTCConfiguration: @unchecked Swift.Sendable {}
4849
extension LKRTCVideoCapturer: @unchecked Swift.Sendable {}
50+
extension LKRTCDefaultAudioProcessingModule: @unchecked Swift.Sendable {}
4951

5052
// MARK: Collections
5153

5254
extension NSHashTable: @unchecked Swift.Sendable {} // cannot specify Obj-C generics
55+
#if swift(<6.2)
5356
extension Dictionary: Swift.Sendable where Key: Sendable, Value: Sendable {}
57+
#endif

Sources/LiveKit/Support/Audio/AudioConverter.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ final class AudioConverter: Sendable {
4545

4646
func convert(from inputBuffer: AVAudioPCMBuffer) {
4747
var error: NSError?
48+
#if swift(>=6.0)
49+
// Won't be accessed concurrently, marking as nonisolated(unsafe) to avoid Atomics.
50+
nonisolated(unsafe) var bufferFilled = false
51+
#else
4852
var bufferFilled = false
53+
#endif
4954

5055
converter.convert(to: outputBuffer, error: &error) { _, outStatus in
5156
if bufferFilled {

Sources/LiveKit/Views/VideoView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public class VideoView: NativeView, Loggable {
231231

232232
// MARK: - Private
233233

234-
#if compiler(>=6.0)
234+
#if swift(>=6.0)
235235
private nonisolated(unsafe) var _primaryRenderer: NativeRendererView?
236236
private nonisolated(unsafe) var _secondaryRenderer: NativeRendererView?
237237
#else

0 commit comments

Comments
 (0)