AppStorage icon indicating copy to clipboard operation
AppStorage copied to clipboard

Better naming

Open xavierLowmiller opened this issue 5 years ago • 2 comments

The name @Persistence does the job, but ideally there should be some way to just call it @AppStorage without name clashes.

Even better, the whole type should disappear on Xcode 12 platforms, where the regular @AppStorage is available.

@unavailable(iOS 14, macOS 11, tvOS 14, watchOS 7, *)

xavierLowmiller avatar Aug 13 '20 18:08 xavierLowmiller

I played around with abusing #if canImport with some iOS 14-exclusive framework as a way to gate the typealias but that doesn't work either, since it's resolved at build-time. Pretty unfortunate that we can't do this properly...

Have you considered making Persistence a simple wrapper around SwiftUI.AppStorage when iOS 14 is available? That way your code doesn't exactly go away, but at least is not used when the platform version is available. This is just off the top of my head, not even sure if it's possible.

As for naming, have you though about borrowing a page from the Android playbook and naming it AppStorageCompat?

fabiorodella avatar Sep 13 '20 16:09 fabiorodella

Have you considered making Persistence a simple wrapper around SwiftUI.AppStorage when iOS 14 is available? That way your code doesn't exactly go away, but at least is not used when the platform version is available. This is just off the top of my head, not even sure if it's possible.

That's a good idea! I'll play around with that later.

As for naming, have you though about borrowing a page from the Android playbook and naming it AppStorageCompat?

I like it. It'll be more obvious than the current name I think.

xavierLowmiller avatar Sep 14 '20 06:09 xavierLowmiller