@AppStorage is built on top of UserDefaults, which is not secure storage. Which mean, you should not save your sensitive data using @AppStorage, because itβs easy for hacker to attack. Which @EncryptedAppStorage, your sensitive data will be saved in KeyChain. Once stored in Keychain this information is only available to your app, other apps can't see it. Besides that, operating system makes sure this information is kept and processed securely.
@EncryptedAppStorage can work with any types of value. If you assign the default value, then that value will be stored in KeyChain if it has no value there.
@EncryptedAppStorage(<#StoreKey#>)
var sensitiveString = "Sensitive String"
@EncryptedAppStorage(<#StoreKey#>)
var sensitiveInt = 100
struct MyObject: Codable {
var name: String
}
@EncryptedAppStorage(<#StoreKey#>)
var myObject: MyObject? = nil
- macOS 11.0+
- iOS 14.0+
- iPadOS 14.0+
- tvOS 14.0+
- watchOS 7.0+
Only available with Swift Package Manager
Khuong β @khuong291