Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCOCOA-2394 RCOCOA-2396 RCOCOA-2397 Build in Swift 6 language mode when supported #8673

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Aug 27, 2024

This drops support for Xcode 15.1 and 15.2 as supporting both Swift 5.9 and 6 at the same time turned out to be an utter mess.

SPM and the Xcode project build in Swift 6 mode when using Xcode 16. CocoaPods always builds in Swift 5 mode since there doesn't appear to be any functional benefit to make it conditional, and it's a bit complicated to do.

Most of the library changes are just replacing @_unsafeInheritExecutor with #isolation, which is the proper official way to achieve the same effect. Sadly it was not added until Swift 6, so a lot of #if is involved. Some of the mongo client functions were incorrectly returning [AnyHashable: String] rather than Document, which now doesn't compile at all so I fixed the return type in Swift 6 mode. Isolated init never got implemented, so try await Realm(actor: actor) has been replaced with try await Realm.open(), since doing the same thing in a static function does work.

Swift used to have a thing where an isolated property wrapper would make the containing type implicitly isolated. This was very confusing and weird so it got removed and the SwiftUI types now need to be explicitly marked as @MainActor.

The changes to tests are mostly boring mechanic changes. Making XCTest subclasses @MainActor didn't actually work, and instead individual test functions need to be marked with it. setUp can't be isolated, so a bunch of test init and deinit had to be adjusted to become thread-safe. waitForExpectations() is main actor isolated while wait(for:) isn't (as it doesn't have the magic global list of expectations), so a bunch of tests were switched to that. @ThreadSafe just plain doesn't work in swift 6 mode due to sendability checking on property wrappers never being implemented, so those tests are disabled.

For some reason the compiler is convinced that QuerySubscription's callback function needs to be Sendable, so a bunch of tests had to be updated to not capture self in that callback.

@cla-bot cla-bot bot added the cla: yes label Aug 27, 2024
@tgoyne tgoyne force-pushed the tg/swift-6 branch 12 times, most recently from 17600c0 to 252a94b Compare September 2, 2024 21:08
@tgoyne tgoyne force-pushed the tg/swift-6 branch 2 times, most recently from a4df969 to fec3b06 Compare September 6, 2024 18:28
@tgoyne tgoyne marked this pull request as ready for review September 6, 2024 19:34
Copy link
Contributor

@leemaguire leemaguire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tgoyne tgoyne merged commit c21605e into master Sep 9, 2024
5 of 62 checks passed
@tgoyne tgoyne deleted the tg/swift-6 branch September 9, 2024 18:27
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants