diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml index 986cf15..93c3f9f 100644 --- a/.github/workflows/swiftlint.yml +++ b/.github/workflows/swiftlint.yml @@ -22,7 +22,7 @@ jobs: name: SwiftLint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: norio-nomura/action-swiftlint@3.2.1 with: args: --strict diff --git a/.github/workflows/xcodebuild.yml b/.github/workflows/xcodebuild.yml index a480f94..596cce5 100644 --- a/.github/workflows/xcodebuild.yml +++ b/.github/workflows/xcodebuild.yml @@ -25,7 +25,7 @@ jobs: - name=Apple TV runs-on: macos-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build run: | xcodebuild \ diff --git a/Sources/FHPropertyWrappers/SecureStored/SecureStorable+SupportedTypes.swift b/Sources/FHPropertyWrappers/SecureStored/SecureStorable+SupportedTypes.swift index 3a5cdc9..4138559 100644 --- a/Sources/FHPropertyWrappers/SecureStored/SecureStorable+SupportedTypes.swift +++ b/Sources/FHPropertyWrappers/SecureStored/SecureStorable+SupportedTypes.swift @@ -28,7 +28,7 @@ extension String: SecureStorable { public static func read(key: SecureStoreKey, accessibility: SecureStoreAccessibility) throws -> String? { let query = _keychainQuery(key: key, accessibility: accessibility) guard let data = try _keychainGet(query: query) else { return nil } - return String(decoding: data, as: UTF8.self) + return String(bytes: data, encoding: .utf8) } public static func write(value: String, for key: SecureStoreKey, accessibility: SecureStoreAccessibility) throws { diff --git a/Sources/FHPropertyWrappers/Stored/Storable+SupportedTypes.swift b/Sources/FHPropertyWrappers/Stored/Storable+SupportedTypes.swift index a0741bb..bb68e23 100644 --- a/Sources/FHPropertyWrappers/Stored/Storable+SupportedTypes.swift +++ b/Sources/FHPropertyWrappers/Stored/Storable+SupportedTypes.swift @@ -119,8 +119,8 @@ extension Array: Storable where Element: RawStorable { return [] } - public static func read(in store: UserDefaults, key: StoreKey) throws -> Array? { - return store.value(forKey: key._value) as? Array + public static func read(in store: UserDefaults, key: StoreKey) throws -> Self? { + return store.value(forKey: key._value) as? Self } public static func write(value: Array, in store: UserDefaults, key: StoreKey) throws { @@ -133,8 +133,8 @@ extension Dictionary: Storable where Key: RawStorable, Value: RawStorable { return [:] } - public static func read(in store: UserDefaults, key: StoreKey) throws -> Dictionary? { - return store.value(forKey: key._value) as? Dictionary + public static func read(in store: UserDefaults, key: StoreKey) throws -> Self? { + return store.value(forKey: key._value) as? Self } public static func write(value: Dictionary, in store: UserDefaults, key: StoreKey) throws { diff --git a/Tests/FHPropertyWrappersTests/SecureStoredTests.swift b/Tests/FHPropertyWrappersTests/SecureStoredTests.swift index 4eceee4..6bdb80a 100644 --- a/Tests/FHPropertyWrappersTests/SecureStoredTests.swift +++ b/Tests/FHPropertyWrappersTests/SecureStoredTests.swift @@ -260,7 +260,7 @@ final class SecureStoredTests: XCTestCase { // swiftlint:disable:this type_body_ string = "string" XCTAssertEqual(string, "string") let data = try XCTUnwrap(_getData(key: $string.key)) - XCTAssertEqual(String(decoding: data, as: UTF8.self), "string") + XCTAssertEqual(String(bytes: data, encoding: .utf8), "string") $string.remove() XCTAssertEqual(string, "") @@ -347,7 +347,7 @@ final class SecureStoredTests: XCTestCase { // swiftlint:disable:this type_body_ optional = "test" XCTAssertEqual(optional, "test") let data = _getData(key: $optional.key) - let string = data.map { String(decoding: $0, as: UTF8.self) } + let string = data.flatMap { String(bytes: $0, encoding: .utf8) } XCTAssertEqual(string, "test") optional = nil @@ -379,7 +379,7 @@ final class SecureStoredTests: XCTestCase { // swiftlint:disable:this type_body_ rawRepresentable = .b XCTAssertEqual(rawRepresentable, .b) let data = try XCTUnwrap(_getData(key: $rawRepresentable.key)) - XCTAssertEqual(String(decoding: data, as: UTF8.self), "b") + XCTAssertEqual(String(bytes: data, encoding: .utf8), "b") $rawRepresentable.remove() XCTAssertEqual(rawRepresentable, .a)