Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix language mode compatibility #158

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
ra1028 marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
19 changes: 16 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Atoms/Core/SubscriberState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<AtomKey>()
nonisolated(unsafe) var unsubscribe: ((Set<AtomKey>) -> Void)?
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -eu

TARGET=$1
PLATFORM=$2
ARGS=${@:3}

pushd "$(cd $(dirname $0)/.. && pwd)" &>/dev/null

Expand All @@ -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