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

Support Swift 6 language mode #15

Merged
merged 4 commits into from
Mar 11, 2025
Merged

Support Swift 6 language mode #15

merged 4 commits into from
Mar 11, 2025

Conversation

mbernson
Copy link
Member

@mbernson mbernson commented Mar 6, 2025

In this PR:

Support Swift 6 language mode

  • Make models conform to Sendable
  • Remove private static 'shared' property because it was not used
  • Mark collection methods as @mainactor

Update Demo app to modern settings

  • Update to modern Xcode project settings
  • Enable Swift 6.0 language mode

mbernson added 2 commits March 6, 2025 14:38
* Make models conform to Sendable
* Remove private static 'shared' property because it was not used
* Mark collection methods as @mainactor
* Update to modern Xcode project settings
* Enable Swift 6.0 language mode
@mbernson mbernson requested a review from edwinveger March 6, 2025 13:40
DispatchQueue.main.async {
self._log(key: "Watch_paired", value: session.isPaired.description)
}
self._log(key: "Watch_paired", value: session.isPaired.description)

Choose a reason for hiding this comment

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

How do we guarantee self._log( is only accessed from the same thread?

  1. Could we make Q42Stats an actor to isolate access to var collected: [String: String]?
    That'd interfere with the WCSessionDelegate conformance though…
  2. Or wrap it in some Box<T>?
actor Box<T: Sendable> {
    private var value: T

    init(_ value: T) {
        self.value = value
    }

    func get() -> T {
        return value
    }

    func set(_ newValue: T) {
        value = newValue
    }
}
  1. Or just mark the property @MainActor 🤷🏻‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

Marking it as @MainActor would have my preference since it's the simplest :)

@mbernson mbernson requested a review from edwinveger March 6, 2025 14:44
@edwinveger
Copy link

By the way, we probably should update Package.swift to 6.0?

@mbernson
Copy link
Member Author

mbernson commented Mar 6, 2025

That might break older project which aren't on Swift 6 yet. Since it's only the minimum tools version, we can leave it for now

@mbernson mbernson merged commit baecc52 into main Mar 11, 2025
@mbernson mbernson deleted the feature/swift-6 branch March 11, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants