diff --git a/Package.swift b/Package.swift index 098130a..51bba80 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( name: "SwiftRepo", platforms: [ - .iOS("18.0"), + .iOS("16.0"), .macOS("15.0"), ], products: [ diff --git a/Sources/SwiftRepo/Repository/ModelResponse.swift b/Sources/SwiftRepo/Repository/ModelResponse.swift index dcc99ca..ed7aa7b 100644 --- a/Sources/SwiftRepo/Repository/ModelResponse.swift +++ b/Sources/SwiftRepo/Repository/ModelResponse.swift @@ -11,6 +11,7 @@ import Foundation /// Partnered with a `QueryRepository` using an additional model store, `Value` will be /// propagated via an `ObservableStore` and the array of `Model`s will be placed in /// the `ModelStore`. +@available(iOS 17, *) public protocol ModelResponse { /// Can be used to propagate additional metadata related to the response via an `ObservableStore` associatedtype Value diff --git a/Sources/SwiftRepo/Repository/Protocols/Query/Query.swift b/Sources/SwiftRepo/Repository/Protocols/Query/Query.swift index f0d535f..6eddbee 100644 --- a/Sources/SwiftRepo/Repository/Protocols/Query/Query.swift +++ b/Sources/SwiftRepo/Repository/Protocols/Query/Query.swift @@ -130,6 +130,7 @@ public extension Query { /// - strategy: The query strategy /// - willGet: A closure that will be called if and when the query is performed. This is typically the `LoadingController.loading` function. /// - Returns: The value if the query was performed. Otherwise, `nil`. + @available(iOS 17, *) func get( id: QueryId, variables: Variables, diff --git a/Sources/SwiftRepo/Repository/Repository/DefaultQueryRepository.swift b/Sources/SwiftRepo/Repository/Repository/DefaultQueryRepository.swift index 410d7b5..f02ef4f 100644 --- a/Sources/SwiftRepo/Repository/Repository/DefaultQueryRepository.swift +++ b/Sources/SwiftRepo/Repository/Repository/DefaultQueryRepository.swift @@ -86,6 +86,7 @@ where QueryId: Hashable, Variables: Hashable, Key: Hashable { /// - queryStrategy: The query strategy to use. /// - valueVariablesFactory: a closure that converts the value into its associated variables /// - keyFactory: a closure that converts the query ID and variables into a store key + @available(iOS 17, *) public init( observableStore: ObservableStoreType, modelStore: any Store, @@ -151,6 +152,7 @@ where QueryId: Hashable, Variables: Hashable, Key: Hashable { /// - mergeStrategy: Specifies how models are stored in the `modelStore`. /// - queryStrategy: The query strategy to use. /// - queryOperation: The operation to use to perform the actual query. + @available(iOS 17, *) public convenience init( observableStore: ObservableStoreType, modelStore: any Store, diff --git a/Sources/SwiftRepo/Repository/Store/PersistentStore.swift b/Sources/SwiftRepo/Repository/Store/PersistentStore.swift index ca8f69e..33ead23 100644 --- a/Sources/SwiftRepo/Repository/Store/PersistentStore.swift +++ b/Sources/SwiftRepo/Repository/Store/PersistentStore.swift @@ -9,6 +9,7 @@ import Foundation import SwiftData /// A persistent `Store` implementation implementation using `SwiftData`. +@available(iOS 18, *) public class PersistentStore: Store { public var keys: [Key] { diff --git a/Sources/SwiftRepo/Repository/Store/SwiftDataStore.swift b/Sources/SwiftRepo/Repository/Store/SwiftDataStore.swift index 569bd63..785bf76 100644 --- a/Sources/SwiftRepo/Repository/Store/SwiftDataStore.swift +++ b/Sources/SwiftRepo/Repository/Store/SwiftDataStore.swift @@ -11,6 +11,7 @@ import SwiftData import SwiftRepoCore // An implementation of `Store` that uses `SwiftData` under the hood +@available(iOS 18, *) public class SwiftDataStore: Store, Saveable where Model: PersistentModel, Model.Key: Hashable & Codable { public typealias Key = Model.Key public typealias Value = Model diff --git a/Sources/SwiftRepo/Repository/StoreModel.swift b/Sources/SwiftRepo/Repository/StoreModel.swift index 512d5b2..06892b6 100644 --- a/Sources/SwiftRepo/Repository/StoreModel.swift +++ b/Sources/SwiftRepo/Repository/StoreModel.swift @@ -11,6 +11,7 @@ import Foundation /// This interface is to be used with models that will be retrieved by the app /// through database queries, rather than published by a `QueryRepository`, /// such as when using SwiftData. +@available(iOS 17, *) public protocol StoreModel { /// The type to use as the identifier for the model associatedtype Key = any Hashable diff --git a/Sources/SwiftRepo/SwiftUI/LoadingControllerView.swift b/Sources/SwiftRepo/SwiftUI/LoadingControllerView.swift index 94fed60..8c4d62a 100644 --- a/Sources/SwiftRepo/SwiftUI/LoadingControllerView.swift +++ b/Sources/SwiftRepo/SwiftUI/LoadingControllerView.swift @@ -45,7 +45,8 @@ public struct LoadingControllerView(@ViewBuilder _ transform: (Self) -> Content) -> some View { + transform(self) + } +} diff --git a/Tests/SwiftRepoTests/DefaultQueryRepositoryTests.swift b/Tests/SwiftRepoTests/DefaultQueryRepositoryTests.swift index 1dbd642..2668e52 100644 --- a/Tests/SwiftRepoTests/DefaultQueryRepositoryTests.swift +++ b/Tests/SwiftRepoTests/DefaultQueryRepositoryTests.swift @@ -32,6 +32,7 @@ class DefaultQueryRepositoryTests: XCTestCase { XCTAssertEqual(spy.publishedValues, [valueA1, valueA1, valueA1, valueA2]) } + @available(iOS 17, *) @MainActor func test_GetSuccess_ModelResponse() async throws { let repo = makeModelResponseStoreRepository( @@ -59,6 +60,7 @@ class DefaultQueryRepositoryTests: XCTestCase { XCTAssertEqual(try modelStore.get(key: Self.modelCId), responseB.models.last) } + @available(iOS 17, *) @MainActor func test_GetSuccess_ModelResponse_Trim() async throws { let repo = makeModelResponseStoreRepository( @@ -87,6 +89,7 @@ class DefaultQueryRepositoryTests: XCTestCase { XCTAssertEqual(try modelStore.get(key: Self.modelCId), responseB.models.last) } + @available(iOS 17, *) @MainActor func test_GetSuccess_ModelResponse_Merge() async throws { let repo = makeModelResponseStoreRepository( @@ -116,6 +119,7 @@ class DefaultQueryRepositoryTests: XCTestCase { XCTAssertEqual(spy.publishedValues.compactMap { $0 as? TestError }, [TestError(category: .failure)]) } + @available(iOS 17, *) func test_GetError_ModelResponse() async throws { let repo = makeModelResponseStoreRepository( delayedValues: DelayedValues(values: [ @@ -259,6 +263,7 @@ class DefaultQueryRepositoryTests: XCTestCase { self.value = value } + @available(iOS 17, *) static func predicate(key: UUID) -> Predicate { #Predicate { $0.id == key } } @@ -320,6 +325,7 @@ class DefaultQueryRepositoryTests: XCTestCase { /// Makes a repository that stores a single value per unique query ID, /// and places ModelResponse values in a separate model store. + @available(iOS 17, *) private func makeModelResponseStoreRepository( mergeStrategy: ModelStoreMergeStrategy = .append, merge: @escaping (_ existing: Model, _ new: Model) -> Model = { _, newValue in newValue }, diff --git a/Tests/SwiftRepoTests/SwiftDataStoreTests.swift b/Tests/SwiftRepoTests/SwiftDataStoreTests.swift index bd3c014..1a855a3 100644 --- a/Tests/SwiftRepoTests/SwiftDataStoreTests.swift +++ b/Tests/SwiftRepoTests/SwiftDataStoreTests.swift @@ -9,6 +9,7 @@ import XCTest import SwiftData @testable import SwiftRepo +@available(iOS 18, *) @MainActor class SwiftDataStoreTests: XCTestCase {