FreemiumKit icon indicating copy to clipboard operation
FreemiumKit copied to clipboard

[Feat] Swift 6 and Observable Framework

Open Maschina opened this issue 8 months ago • 2 comments

Problem Statement

I see that the library still relies on non-6.0 compatible code base and old ObservableObject framework.

Suggested Solution

Upgrade or extend with modern 6.0 compatible code base that relies on the much faster Observable framework.

Maschina avatar Apr 07 '25 18:04 Maschina

@Maschina Thank you for bringing this up. I'm happy to discuss the possibilities here.

I had considered using the Observation framework from the start, but unfortunately it's not available on iOS 16 and iOS 15, but FreemiumKit supports both of these platform versions. So other than providing two separate libraries, which would be a lot of additional maintenance, I don't see how I could support the Observation framework for the time being. One day, when iOS 16 becomes irrelevant, I might be able to drop it and migrate, but for now I would be interested if there's any downside with using ObservableObject. It's still fully supported AFAIK.

As for the Swift 6.0 compatibility, I don't quite understand how the code is "non-6.0 compatible"? Swift 6 fully supports Swift 5.10, which is the minimum required version for FreemiumKit. But I don't see how this is a problem? Please let me know.

Jeehut avatar Apr 08 '25 09:04 Jeehut

@Jeehut I agree with your decision to not maintain two different frameworks as long as iOS 16 is not yet irrelevant.

Regarding Swift 6.0 compatibility, I was primarily referring to setting the Swift 6 language mode in the Package.swift file and the handling of the shared singleton. It appears that the singleton is not bound to an actor, which could potentially lead to data races based on the interfaces I’ve examined. I stumbled upon this while setting legacyProductsIDsByTier through the shared singleton. However, I might be mistaken and have misinterpreted the situation.

Maschina avatar Apr 08 '25 15:04 Maschina