-
Notifications
You must be signed in to change notification settings - Fork 49
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
Swift 6 Compatibility and class property warning #127
Comments
@adilrc thanks for reporting, did you change any configuration to get this warning? I am also using Xcode 15.3 but I don't get this warning. (Swift v6 isn't released yet either). |
Yes I do have strict concurrency checks enabled in my package along with Swift 5.10. .target(
...
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency")
]
) |
Yep I figured via Xcode project file as well |
I believe @adilrc made a small typo. The SPM setting is: .enableExperimentalFeature("StrictConcurrency"), You can control the type of strict concurrency by following the attribute with
If I may offer some advice in how to go about removing the concurrency warnings and making
public class PostHogSDK: NSObject {
@objc public nonisolated(unsafe) static let shared = PostHogSDK(PostHogConfig(apiKey: ""))
} |
|
Yes, the
In any case, this all goes to say that making the whole SDK properly conform to Swift 6 strict concurrency might be hard (not impossible, though). Since we have a zero warning policy in our CI, PostHog SDK is currently not letting us jump into Xcode 15.3. We might have to hardcode some exception for PostHog, but I would rather avoid that. That is why i was suggesting the |
Yep makes sense, I'm checking how to remove all the warnings without breaking changes, see PR. |
Seems like a good plan! I briefly checked your PR and it looks like you are applying major changes. For example:
Regardless, my suggestion is to perform minimal changes to the current PostHog version. For the library users, we only have a single warning when accessing |
Hey @dehesa, good points. The I was not aware of the performance boost by marking them as It's just a draft PR that I am using to learn more about the new strict concurrency since I have not played with it before, no intention to merge it as it is but thanks for calling it out. |
@dehesa the problem is that |
You are correct! I believe you can do the following: #if swift(>=5.10)
@objc public nonisolated(unsafe) static let shared = PostHogSDK(PostHogConfig(apiKey: ""))
#else
@objc public static let shared = PostHogSDK(PostHogConfig(apiKey: ""))
#endif |
Hey @marandaneto. Any chance you can do a hotfix or minor release to remove the warning from our CI? |
sorry the delay, https://github.com/PostHog/posthog-ios/releases/tag/3.3.0 |
Problem Statement
I'm using your SDK with Xcode 15.3, and I'm getting a warning about a static property not being concurrency-safe. Can you please update the SDK to make it Swift 6 compatible and fix the warning?
Here's the warning I'm getting in PostHogSDK.swift:54:
Class property 'shared' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6
Thanks!
Solution Brainstorm
No response
The text was updated successfully, but these errors were encountered: