@@ -33,6 +33,7 @@ import OneSignalCore
3333///
3434/// Stored in the App Group container, so it's shared across any targets (main app, NSE, etc.)
3535/// configured with the same App Group entitlement. Opaque identifiers only: no PII or credentials.
36+ /// Accessors are no-ops on Mac Catalyst, where iOS data protection and prewarming do not apply.
3637@ objc ( OSResilientStorage )
3738public final class OSResilientStorage : NSObject {
3839
@@ -50,6 +51,14 @@ public final class OSResilientStorage: NSObject {
5051
5152 // MARK: - Internal
5253
54+ private static var isSupported : Bool {
55+ #if targetEnvironment( macCatalyst )
56+ return false
57+ #else
58+ return true
59+ #endif
60+ }
61+
5362 private static let fileName = " onesignal_identity.json "
5463
5564 /// Serial queue used to serialize all file reads/writes.
@@ -158,6 +167,7 @@ public final class OSResilientStorage: NSObject {
158167
159168 /// Returns the full current contents of the cache. Empty dict if absent.
160169 @ objc public static func snapshot ( ) -> [ String : String ] {
170+ guard isSupported else { return [ : ] }
161171 return queue . sync { loadUnsafe ( ) }
162172 }
163173
@@ -170,6 +180,7 @@ public final class OSResilientStorage: NSObject {
170180
171181 /// Atomically updates a single value. Passing nil or an empty string removes the key.
172182 @ objc public static func setString ( _ value : String ? , forKey key : String ) {
183+ guard isSupported else { return }
173184 queue . async {
174185 var current = loadUnsafe ( )
175186 if let value = value , ! value . isEmpty {
@@ -184,7 +195,7 @@ public final class OSResilientStorage: NSObject {
184195 /// Atomically updates multiple values, preserving keys not in `values`.
185196 /// An empty-string value removes the corresponding key.
186197 @ objc public static func setStrings ( _ values : [ String : String ] ) {
187- guard ! values . isEmpty else { return }
198+ guard isSupported , ! values . isEmpty else { return }
188199 queue . async {
189200 var current = loadUnsafe ( )
190201 for ( key , value ) in values {
0 commit comments