diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55f0e483..c2de655a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,16 +45,29 @@ jobs: - name: Test example tvOS run: scripts/test.sh example-cross-platform tvos - upcoming_feature: - name: Upcoming features + test_upcoming_features: + name: Test upcoming features with Xcode 15 runs-on: macos-14 env: DEVELOPER_DIR: /Applications/Xcode_15.4.app steps: - uses: actions/checkout@v4 - - name: Test with upcoming features + - name: Test upcoming features run: ENABLE_UPCOMING_FEATURES=1 scripts/test.sh library ios + test_language_mode: + name: Test Swift 5 language mode + runs-on: macos-14 + strategy: + matrix: + enable_upcoming_features: + - 0 + - 1 + steps: + - uses: actions/checkout@v4 + - name: Test Swift 5 language mode + run: ENABLE_UPCOMING_FEATURES=${{ matrix.enable_upcoming_features }} scripts/test.sh library ios SWIFT_VERSION=5 + benchmark: name: Benchmark runs-on: macos-14 diff --git a/Package.swift b/Package.swift index e8c74627..de290413 100644 --- a/Package.swift +++ b/Package.swift @@ -2,9 +2,22 @@ import PackageDescription -let swiftSettings: [SwiftSetting] = [ - .enableUpcomingFeature("ExistentialAny") -] +let swiftSettings: [SwiftSetting] + +if Context.environment["ENABLE_UPCOMING_FEATURES"] == "1" { + swiftSettings = [ + .enableUpcomingFeature("DisableOutwardActorInference"), + .enableUpcomingFeature("InferSendableFromCaptures"), + .enableUpcomingFeature("IsolatedDefaultValues"), + .enableUpcomingFeature("StrictConcurrency"), + .enableUpcomingFeature("ExistentialAny"), + ] +} +else { + swiftSettings = [ + .enableUpcomingFeature("ExistentialAny") + ] +} let package = Package( name: "swiftui-atom-properties", diff --git a/Package@swift-5.swift b/Package@swift-5.swift index 641530b8..fa62d687 100644 --- a/Package@swift-5.swift +++ b/Package@swift-5.swift @@ -4,10 +4,11 @@ import PackageDescription let swiftSettings: [SwiftSetting] -if Context.environment["ENABLE_UPCOMING_FEATURES"] != nil { +if Context.environment["ENABLE_UPCOMING_FEATURES"] == "1" { swiftSettings = [ - .enableUpcomingFeature("ExistentialAny"), .enableUpcomingFeature("DisableOutwardActorInference"), + .enableUpcomingFeature("IsolatedDefaultValues"), + .enableUpcomingFeature("ExistentialAny"), ] } else { diff --git a/Sources/Atoms/Core/SubscriberState.swift b/Sources/Atoms/Core/SubscriberState.swift index 07b1fd3c..7dcd6be2 100644 --- a/Sources/Atoms/Core/SubscriberState.swift +++ b/Sources/Atoms/Core/SubscriberState.swift @@ -4,6 +4,10 @@ import Foundation internal final class SubscriberState { let token = SubscriberKey.Token() + #if !hasFeature(IsolatedDefaultValues) + nonisolated init() {} + #endif + #if compiler(>=6) nonisolated(unsafe) var subscribing = Set() nonisolated(unsafe) var unsubscribe: ((Set) -> Void)? @@ -34,10 +38,6 @@ internal final class SubscriberState { _modify { yield &_unsubscribe.value } } - #if hasFeature(DisableOutwardActorInference) - nonisolated init() {} - #endif - deinit { if Thread.isMainThread { _unsubscribe.value?(_subscribing.value) diff --git a/scripts/test.sh b/scripts/test.sh index 74f68232..7a905f57 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -4,6 +4,7 @@ set -eu TARGET=$1 PLATFORM=$2 +ARGS=${@:3} pushd "$(cd $(dirname $0)/.. && pwd)" &>/dev/null @@ -22,20 +23,24 @@ watchos) ;; esac +clean_test() { + xcodebuild clean test "$@" $ARGS +} + case $TARGET in library) - xcodebuild clean test -scheme swiftui-atom-properties -destination platform="$platform" + clean_test -scheme swiftui-atom-properties -destination platform="$platform" ;; example-ios) cd Examples/Packages/iOS - xcodebuild clean test -scheme iOSExamples -destination platform="$platform" + clean_test -scheme iOSExamples -destination platform="$platform" ;; example-cross-platform) cd Examples/Packages/CrossPlatform - xcodebuild clean test -scheme CrossPlatformExamples -destination platform="$platform" + clean_test -scheme CrossPlatformExamples -destination platform="$platform" ;; benchmark) cd Benchmarks - xcodebuild clean test -scheme BenchmarkTests -destination platform="$platform" + clean_test -scheme BenchmarkTests -destination platform="$platform" ;; esac