diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 2ad8567..fbfb8ff 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -13,3 +13,4 @@ SpeziStorage contributors * [Paul Schmiedmayer](https://github.com/PSchmiedmayer) * [Vishnu Ravi](https://github.com/vishnuravi) +* [Andreas Bauer](https://github.com/Supereg) diff --git a/Package.swift b/Package.swift index eb1f496..8f64e45 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.9 // // This source file is part of the Stanford Spezi open-source project @@ -14,14 +14,14 @@ import PackageDescription let package = Package( name: "SpeziStorage", platforms: [ - .iOS(.v16) + .iOS(.v17) ], products: [ .library(name: "SpeziLocalStorage", targets: ["SpeziLocalStorage"]), .library(name: "SpeziSecureStorage", targets: ["SpeziSecureStorage"]) ], dependencies: [ - .package(url: "https://github.com/StanfordSpezi/Spezi", .upToNextMinor(from: "0.7.0")), + .package(url: "https://github.com/StanfordSpezi/Spezi", .upToNextMinor(from: "0.8.0")), .package(url: "https://github.com/StanfordBDHG/XCTRuntimeAssertions", .upToNextMinor(from: "0.2.5")) ], targets: [ diff --git a/README.md b/README.md index 8ad2431..e2347f3 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ You can then use the [`LocalStorage`](https://swiftpackageindex.com/stanfordspez ```swift struct ExampleStorageView: View { - @EnvironmentObject var secureStorage: LocalStorage - @EnvironmentObject var secureStorage: SecureStorage + @Environment(LocalStorage.self) var secureStorage + @Environment(SecureStorage.self) var secureStorage var body: some View { diff --git a/Sources/SpeziLocalStorage/LocalStorage.swift b/Sources/SpeziLocalStorage/LocalStorage.swift index d257d76..2065f73 100644 --- a/Sources/SpeziLocalStorage/LocalStorage.swift +++ b/Sources/SpeziLocalStorage/LocalStorage.swift @@ -18,7 +18,7 @@ import SpeziSecureStorage /// Use ``LocalStorage/store(_:storageKey:settings:)`` to store elements on disk and define the settings using a ``LocalStorageSetting`` instance. /// /// Use ``LocalStorage/read(_:storageKey:settings:)`` to read elements on disk which are decoded as define by passed in ``LocalStorageSetting`` instance. -public final class LocalStorage: Module, DefaultInitializable { +public final class LocalStorage: Module, DefaultInitializable, EnvironmentAccessible { private let encryptionAlgorithm: SecKeyAlgorithm = .eciesEncryptionCofactorX963SHA256AESGCM @Dependency private var secureStorage = SecureStorage() diff --git a/Sources/SpeziLocalStorage/SpeziLocalStorage.docc/SpeziLocalStorage.md b/Sources/SpeziLocalStorage/SpeziLocalStorage.docc/SpeziLocalStorage.md index 7c721bd..aeb42c6 100644 --- a/Sources/SpeziLocalStorage/SpeziLocalStorage.docc/SpeziLocalStorage.md +++ b/Sources/SpeziLocalStorage/SpeziLocalStorage.docc/SpeziLocalStorage.md @@ -49,7 +49,7 @@ You can then use the ``LocalStorage`` class in any SwiftUI view. ```swift struct ExampleStorageView: View { - @EnvironmentObject var localStorage: LocalStorage + @Environment(LocalStorage.self) var localStorage var body: some View { diff --git a/Sources/SpeziSecureStorage/SecureStorage.swift b/Sources/SpeziSecureStorage/SecureStorage.swift index 1611960..bbf9b7e 100644 --- a/Sources/SpeziSecureStorage/SecureStorage.swift +++ b/Sources/SpeziSecureStorage/SecureStorage.swift @@ -17,7 +17,7 @@ import XCTRuntimeAssertions /// The ``SecureStorage`` serves as a reusable `Module` that can be used to store small chunks of data such as credentials and keys. /// /// The storing of credentials and keys follows the Keychain documentation provided by Apple: https://developer.apple.com/documentation/security/keychain_services/keychain_items/using_the_keychain_to_manage_user_secrets. -public final class SecureStorage: Module, DefaultInitializable { +public final class SecureStorage: Module, DefaultInitializable, EnvironmentAccessible { /// The ``SecureStorage`` serves as a reusable `Module` that can be used to store store small chunks of data such as credentials and keys. /// /// The storing of credentials and keys follows the Keychain documentation provided by Apple: diff --git a/Sources/SpeziSecureStorage/SpeziSecureStorage.docc/SpeziSecureStorage.md b/Sources/SpeziSecureStorage/SpeziSecureStorage.docc/SpeziSecureStorage.md index 4feeed8..76a5d78 100644 --- a/Sources/SpeziSecureStorage/SpeziSecureStorage.docc/SpeziSecureStorage.md +++ b/Sources/SpeziSecureStorage/SpeziSecureStorage.docc/SpeziSecureStorage.md @@ -49,7 +49,7 @@ You can then use the ``SecureStorage`` class in any SwiftUI view. ```swift struct ExampleStorageView: View { - @EnvironmentObject var secureStorage: SecureStorage + @Environment(SecureStorage.self) var secureStorage var body: some View { diff --git a/Tests/UITests/TestApp/LocalStorageTests/LocalStorageTestsView.swift b/Tests/UITests/TestApp/LocalStorageTests/LocalStorageTestsView.swift index e63771b..67064b4 100644 --- a/Tests/UITests/TestApp/LocalStorageTests/LocalStorageTestsView.swift +++ b/Tests/UITests/TestApp/LocalStorageTests/LocalStorageTestsView.swift @@ -13,9 +13,9 @@ import XCTestApp struct LocalStorageTestsView: View { - @EnvironmentObject var localStorage: LocalStorage - @EnvironmentObject var secureStorage: SecureStorage - + @Environment(LocalStorage.self) var localStorage + @Environment(SecureStorage.self) var secureStorage + var body: some View { TestAppView(testCase: LocalStorageTests(localStorage: localStorage, secureStorage: secureStorage)) diff --git a/Tests/UITests/TestApp/SecureStorageTests/SecureStorageTestsView.swift b/Tests/UITests/TestApp/SecureStorageTests/SecureStorageTestsView.swift index e7b4604..651e0ae 100644 --- a/Tests/UITests/TestApp/SecureStorageTests/SecureStorageTestsView.swift +++ b/Tests/UITests/TestApp/SecureStorageTests/SecureStorageTestsView.swift @@ -12,7 +12,7 @@ import XCTestApp struct SecureStorageTestsView: View { - @EnvironmentObject var secureStorage: SecureStorage + @Environment(SecureStorage.self) var secureStorage var body: some View { diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index e4490df..b170dc7 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -350,7 +350,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -404,7 +404,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -567,7 +567,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES;