diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b60f973..960f4f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,8 +33,11 @@ jobs: xcode: 14.2 # Swift 5.7 sim: iPhone 14 - os: macos-13 - xcode: 14.3 # Swift 5.8 + xcode: 14.3.1 # Swift 5.8 sim: iPhone 14 + - os: macos-13 + xcode: '15.0' # Swift 5.9 + sim: iPhone 15 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 24e161d..5fab919 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -602,6 +602,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_STRICT_CONCURRENCY = complete; }; name = Debug; }; @@ -656,6 +657,7 @@ SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_STRICT_CONCURRENCY = complete; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/Example/Shared/Sources/Shared/ContentView.swift b/Example/Shared/Sources/Shared/ContentView.swift index a427e56..cf5d963 100644 --- a/Example/Shared/Sources/Shared/ContentView.swift +++ b/Example/Shared/Sources/Shared/ContentView.swift @@ -9,7 +9,6 @@ import PickBetter import SwiftUI -@MainActor public struct ContentView: View { @State private var tab: TabOption = .singleValue @State private var isGridStyle: Bool = true diff --git a/Example/Shared/Sources/Shared/ItemLabel.swift b/Example/Shared/Sources/Shared/ItemLabel.swift index 99386d2..adbddcb 100644 --- a/Example/Shared/Sources/Shared/ItemLabel.swift +++ b/Example/Shared/Sources/Shared/ItemLabel.swift @@ -9,7 +9,6 @@ import Foundation import SwiftUI -@MainActor public struct ItemLabel: View { private let itemId: String diff --git a/Example/Shared/Sources/Shared/LazyView.swift b/Example/Shared/Sources/Shared/LazyView.swift index c9ec1f3..fb4f0d7 100644 --- a/Example/Shared/Sources/Shared/LazyView.swift +++ b/Example/Shared/Sources/Shared/LazyView.swift @@ -9,7 +9,6 @@ import Foundation import SwiftUI -@MainActor public struct LazyView: View where Content: View { private let content: () -> Content diff --git a/Example/Shared/Sources/Shared/MultiValueSelection.swift b/Example/Shared/Sources/Shared/MultiValueSelection.swift index 4b32909..51902c2 100644 --- a/Example/Shared/Sources/Shared/MultiValueSelection.swift +++ b/Example/Shared/Sources/Shared/MultiValueSelection.swift @@ -10,7 +10,6 @@ import Foundation import PickBetter import SwiftUI -@MainActor public struct MultiValueSelection: View { private let items: [Item] private let isGridStyle: Bool diff --git a/Example/Shared/Sources/Shared/RouteView.swift b/Example/Shared/Sources/Shared/RouteView.swift index cd662d2..12d4fd0 100644 --- a/Example/Shared/Sources/Shared/RouteView.swift +++ b/Example/Shared/Sources/Shared/RouteView.swift @@ -9,7 +9,6 @@ import Foundation import SwiftUI -@MainActor public struct RouterView: View where Links: View, Content: View { @Binding private var selection: AnyHashable private let links: (Binding) -> Links @@ -40,7 +39,6 @@ public struct RouterView: View where Links: View, Content: View } } -@MainActor public struct RouteView: View where Route: Hashable, Label: View, Destination: View { private let route: AnyHashable @Binding private var selection: AnyHashable diff --git a/Example/Shared/Sources/Shared/SingleOptionalValueSelection.swift b/Example/Shared/Sources/Shared/SingleOptionalValueSelection.swift index 4996318..ffeb3e6 100644 --- a/Example/Shared/Sources/Shared/SingleOptionalValueSelection.swift +++ b/Example/Shared/Sources/Shared/SingleOptionalValueSelection.swift @@ -10,7 +10,6 @@ import Foundation import PickBetter import SwiftUI -@MainActor public struct SingleOptionalValueSelection: View { private let items: [Item] private let isGridStyle: Bool diff --git a/Example/Shared/Sources/Shared/SingleValueSelection.swift b/Example/Shared/Sources/Shared/SingleValueSelection.swift index 2dc8df9..1dd6790 100644 --- a/Example/Shared/Sources/Shared/SingleValueSelection.swift +++ b/Example/Shared/Sources/Shared/SingleValueSelection.swift @@ -10,7 +10,6 @@ import Foundation import PickBetter import SwiftUI -@MainActor public struct SingleValueSelection: View { private let items: [Item] private let isGridStyle: Bool diff --git a/Package.swift b/Package.swift index 258b49a..1fb14fe 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,6 @@ let package = Package( targets: ["PickBetter"] ), ], - dependencies: [], targets: [ .target(name: "PickBetter"), ] diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift new file mode 100644 index 0000000..b00caf5 --- /dev/null +++ b/Package@swift-5.8.swift @@ -0,0 +1,33 @@ +// swift-tools-version:5.8 + +import PackageDescription + +let package = Package( + name: "swiftui-pick-better", + platforms: [ + .iOS(.v14), + .macOS(.v11), + .watchOS(.v7), + .tvOS(.v14), + ], + products: [ + .library( + name: "PickBetter", + targets: ["PickBetter"] + ), + ], + targets: [ + .target(name: "PickBetter"), + ] +) + +package.targets.strictConcurrency() + +extension Array where Element == Target { + func strictConcurrency() { + forEach { target in + target.swiftSettings = (target.swiftSettings ?? []) + + [.enableUpcomingFeature("StrictConcurrency")] + } + } +} diff --git a/Sources/PickBetter/BetterPicker.swift b/Sources/PickBetter/BetterPicker.swift index fb24e1a..9ccd2ce 100644 --- a/Sources/PickBetter/BetterPicker.swift +++ b/Sources/PickBetter/BetterPicker.swift @@ -10,7 +10,6 @@ import Foundation import SwiftUI /// A custom implementation of a 'Picker' UI element with less magic than SwiftUI's provided `Picker` -@MainActor public struct BetterPicker: View where SelectionBox: BetterPickerSelection, ItemContent: View { @@ -67,7 +66,7 @@ public struct BetterPicker: View where SelectionBox: fileprivate static func itemsFromData( _ data: Data, selectionValue: @escaping (Data.Element) -> SelectionValue, - content: @MainActor @escaping (Data.Element) -> ItemContent + content: @escaping (Data.Element) -> ItemContent ) -> [ItemTuple] where Data: Sequence { data.map { item in (selectionValue(item), { content(item) }) } } @@ -84,7 +83,7 @@ public struct BetterPicker: View where SelectionBox: _ data: Data, selectionValue: @escaping (Data.Element) -> SelectionValue, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, SelectionBox == SingleSelectionWrapper { let selectionBinding: Binding> = Binding( get: { SingleSelectionWrapper(value: selection.wrappedValue) }, @@ -106,7 +105,7 @@ public struct BetterPicker: View where SelectionBox: _ data: Data, selectionValue: @escaping (Data.Element) -> SelectionValue, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, SelectionBox == Selection? { self.init( items: Self.itemsFromData(data, selectionValue: selectionValue, content: content), @@ -126,7 +125,7 @@ extension BetterPicker where SelectionBox: Sequence { _ data: Data, selectionValue: @escaping (Data.Element) -> SelectionValue, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element == SelectionBox.SelectionValue { self.init( items: Self.itemsFromData(data, selectionValue: selectionValue, content: content), @@ -146,7 +145,7 @@ extension BetterPicker { public init( _ data: Data, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element == SelectionValue, SelectionBox == SingleSelectionWrapper { @@ -168,7 +167,7 @@ extension BetterPicker { public init( _ data: Data, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element == Selection, SelectionBox == Selection? { @@ -188,7 +187,7 @@ extension BetterPicker where SelectionBox: Sequence { public init( _ data: Data, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element == SelectionBox.SelectionValue { self.init( items: Self.itemsFromData(data, selectionValue: { $0 }, content: content), @@ -208,7 +207,7 @@ extension BetterPicker { public init( _ data: Data, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element: Identifiable, Data.Element.ID == SelectionValue, SelectionBox == SingleSelectionWrapper { @@ -227,7 +226,7 @@ extension BetterPicker { public init( _ data: Data, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element: Identifiable, Data.Element.ID == Selection, SelectionBox == Selection? { @@ -247,7 +246,7 @@ extension BetterPicker where SelectionBox: Sequence { public init( _ data: Data, selection: Binding, - @ViewBuilder content: @MainActor @escaping (Data.Element) -> ItemContent + @ViewBuilder content: @escaping (Data.Element) -> ItemContent ) where Data: Sequence, Data.Element: Identifiable, SelectionBox.Element == Data.Element.ID, SelectionBox.Element == SelectionBox.SelectionValue { diff --git a/Sources/PickBetter/Internal/CellWrapper.swift b/Sources/PickBetter/Internal/CellWrapper.swift index 707b39f..fbd7e33 100644 --- a/Sources/PickBetter/Internal/CellWrapper.swift +++ b/Sources/PickBetter/Internal/CellWrapper.swift @@ -9,7 +9,6 @@ import Foundation import SwiftUI -@MainActor struct CellWrapper: View where Content: View { let isSelected: Bool let content: Content diff --git a/Sources/PickBetter/PlainInlineBetterPickerStyle.swift b/Sources/PickBetter/PlainInlineBetterPickerStyle.swift index bcfdaaf..80fe599 100644 --- a/Sources/PickBetter/PlainInlineBetterPickerStyle.swift +++ b/Sources/PickBetter/PlainInlineBetterPickerStyle.swift @@ -40,14 +40,12 @@ public struct PlainInlineBetterPickerStyle: BetterPickerStyle { let id: String } - @MainActor private var items: [PreviewItem] = ["A", "B", "C"].map { PreviewItem(id: $0) } private func itemContent(_ item: PreviewItem) -> some View { Text(item.id) } - @MainActor struct PlainInlineBetterPickerStyle_Previews: PreviewProvider { static var previews: some View { Group { @@ -58,7 +56,6 @@ public struct PlainInlineBetterPickerStyle: BetterPickerStyle { } } - @MainActor private struct OptionalSelectionPreview: View { @State private var selection: PreviewItem.ID? @@ -71,7 +68,6 @@ public struct PlainInlineBetterPickerStyle: BetterPickerStyle { } } - @MainActor private struct SingleSelectionPreview: View { @State private var selection: PreviewItem.ID = items.first!.id @@ -84,7 +80,6 @@ public struct PlainInlineBetterPickerStyle: BetterPickerStyle { } } - @MainActor private struct MultiSelectionPreview: View { @State private var selection: Set = []