Skip to content

Commit

Permalink
Merge pull request #8 from MFB-Technologies-Inc/add-mainactor-and-vie…
Browse files Browse the repository at this point in the history
…wbuilder-where-needed

Add @mainactor and @ViewBuilder where needed
  • Loading branch information
r-jarvis authored Oct 20, 2023
2 parents 8586ee2 + 4df9985 commit 4af0029
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 40 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
- os: macos-12
xcode: 13.4.1 # Swift 5.6
sim: iPhone 13
- os: macos-13
xcode: 14.2 # Swift 5.7
sim: iPhone 14
- os: macos-13
xcode: 14.3.1 # Swift 5.8
sim: iPhone 14
Expand All @@ -43,5 +40,7 @@ jobs:
- uses: actions/checkout@v3
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Boot simulator
run: xcrun simctl boot '${{ matrix.sim }}'
- name: Run tests
run: xcodebuild -project ./Example/Example.xcodeproj -scheme Example test -destination platform='iOS Simulator',name='${{ matrix.sim }}' -quiet -enableCodeCoverage YES -derivedDataPath "./output"
18 changes: 10 additions & 8 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.mfbtech.picker-better.Example-macOS";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -472,7 +472,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.mfbtech.picker-better.Example-macOS";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -510,7 +510,7 @@
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 14.0;
TVOS_DEPLOYMENT_TARGET = 15.0;
};
name = Debug;
};
Expand Down Expand Up @@ -540,7 +540,7 @@
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 14.0;
TVOS_DEPLOYMENT_TARGET = 15.0;
};
name = Release;
};
Expand Down Expand Up @@ -595,14 +595,15 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -651,13 +652,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -679,7 +681,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -717,7 +719,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
11 changes: 5 additions & 6 deletions Example/Shared/Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// swift-tools-version: 5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version: 5.5

import PackageDescription

let package = Package(
name: "Shared",
platforms: [
.iOS(.v14),
.macOS(.v11),
.watchOS(.v7),
.tvOS(.v14),
.iOS(.v15),
.macOS(.v12),
.watchOS(.v8),
.tvOS(.v15),
],
products: [
.library(
Expand Down
38 changes: 38 additions & 0 deletions Example/Shared/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// swift-tools-version: 5.8

import PackageDescription

let package = Package(
name: "Shared",
platforms: [
.iOS(.v15),
.macOS(.v12),
.watchOS(.v8),
.tvOS(.v15),
],
products: [
.library(
name: "Shared",
targets: ["Shared"]
),
],
dependencies: [
.package(name: "swiftui-pick-better", path: "../../"),
],
targets: [
.target(
name: "Shared",
dependencies: [
.product(name: "PickBetter", package: "swiftui-pick-better"),
],
swiftSettings: [
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ImplicitOpenExistentials"),
.enableUpcomingFeature("StrictConcurrency"),
]
),
]
)
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import PackageDescription
let package = Package(
name: "swiftui-pick-better",
platforms: [
.iOS(.v14),
.macOS(.v11),
.watchOS(.v7),
.tvOS(.v14),
.iOS(.v15),
.macOS(.v12),
.watchOS(.v8),
.tvOS(.v15),
],
products: [
.library(
Expand Down
31 changes: 15 additions & 16 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import PackageDescription
let package = Package(
name: "swiftui-pick-better",
platforms: [
.iOS(.v14),
.macOS(.v11),
.watchOS(.v7),
.tvOS(.v14),
.iOS(.v15),
.macOS(.v12),
.watchOS(.v8),
.tvOS(.v15),
],
products: [
.library(
Expand All @@ -17,17 +17,16 @@ let package = Package(
),
],
targets: [
.target(name: "PickBetter"),
.target(
name: "PickBetter",
swiftSettings: [
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ImplicitOpenExistentials"),
.enableUpcomingFeature("StrictConcurrency"),
]
),
]
)

package.targets.strictConcurrency()

extension Array where Element == Target {
func strictConcurrency() {
forEach { target in
target.swiftSettings = (target.swiftSettings ?? [])
+ [.enableUpcomingFeature("StrictConcurrency")]
}
}
}
2 changes: 1 addition & 1 deletion Sources/PickBetter/BetterPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public struct BetterPicker<SelectionBox, ItemContent>: View where SelectionBox:
/// - style: `Style` (BetterPickerStyle)
/// - Returns
/// - `some View`
public func betterPickerStyle<Style: BetterPickerStyle>(_ style: Style) -> some View {
@MainActor public func betterPickerStyle<Style: BetterPickerStyle>(_ style: Style) -> some View {
let styledItems: [(SelectionValue, () -> CellWrapper<Style.ListCellOutput>)] = items
.map { item in
let configuration = Style.CellConfiguration(
Expand Down
4 changes: 2 additions & 2 deletions Sources/PickBetter/BetterPickerStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public protocol BetterPickerStyle {
/// - configuration: `BetterPickerStyleConfiguration`
/// - Returns
/// - `ViewOutput`
func makeView(_ configuration: Configuration) -> ViewOutput
@ViewBuilder @MainActor func makeView(_ configuration: Configuration) -> ViewOutput

/// Builds each cell view
/// - Parameters
/// - configuration: `BetterPickerStyleListCellConfiguration`
/// - Returns
/// - `ListCellOutput`
func makeListCell(_ configuration: CellConfiguration) -> ListCellOutput
@ViewBuilder @MainActor func makeListCell(_ configuration: CellConfiguration) -> ListCellOutput
}

0 comments on commit 4af0029

Please sign in to comment.