When creating an archive build using Xcode 16 (beta) and Swift 6 enabled, I'm seeing a build error that doesn't exist when creating a debug build (build and run or unit tests) that I'm not sure about the best approach for fixing.
The error I'm seeing is related to the swift-dependencies SPM package from PointFree and a GitHub issue has been raised here to try and look at a solution. Unfortunately my understanding is a bit limited as to what the best approach to take here would be.
The error:
swift-dependencies/Sources/Dependencies/WithDependencies.swift:491:17 Non-sendable type 'R' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
The code snipped causing the issue:
#if swift(>=6)
@_transparent
private func isSetting<R>(
_ value: Bool,
isolation: isolated (any Actor)? = #isolation,
operation: () async throws -> R
) async rethrows -> R {
#if DEBUG
try await DependencyValues.$isSetting.withValue(value, operation: operation)
#else
try await operation()
#endif
}
#else
@_transparent
private func isSetting<R>(
_ value: Bool,
operation: () async throws -> R
) async rethrows -> R {
#if DEBUG
try await DependencyValues.$isSetting.withValue(value, operation: operation)
#else
try await operation()
#endif
}
#endif
The Fix-it of applying Sendable
to the generic type R
is one option, though with it only being an error when doing release / archive builds I'm a bit confused as to whether it's a good approach.
Are there any other solutions that could be looked at?
Thanks,
Amy.