diff --git a/.github/workflows/swift-compatibility.yml b/.github/workflows/swift-compatibility.yml index 742f4d6..e4d96be 100644 --- a/.github/workflows/swift-compatibility.yml +++ b/.github/workflows/swift-compatibility.yml @@ -22,25 +22,42 @@ jobs: name: Swift 6.0 compatibility runs-on: macos-15 timeout-minutes: 20 - env: - DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 - - name: Report toolchain + # Xcode 16.0, 16.1 and 16.2 all ship Swift 6.0.x, so any of them proves + # the same thing. Some runner instances come up with no iOS platform + # installed for a given Xcode, so pick the first that can actually + # resolve an iOS destination rather than pinning one. `-showsdks` is not + # a usable test here: on a stripped runner it still lists iphoneos while + # the platform itself is missing, so ask for destinations instead. + - name: Select a Swift 6.0 Xcode that can build for iOS run: | - xcodebuild -version - swift --version + for app in /Applications/Xcode_16.app /Applications/Xcode_16.1.app /Applications/Xcode_16.2.app; do + developer_dir="$app/Contents/Developer" + [ -d "$developer_dir" ] || continue + if DEVELOPER_DIR="$developer_dir" xcodebuild -showdestinations -scheme ILikeToMoveIt 2>/dev/null \ + | grep 'name:Any iOS Device' | grep -qv 'error:'; then + echo "Using $app" + DEVELOPER_DIR="$developer_dir" xcodebuild -version + DEVELOPER_DIR="$developer_dir" swift --version + echo "DEVELOPER_DIR=$developer_dir" >> "$GITHUB_ENV" + exit 0 + fi + echo "$app has no installed iOS platform" + done + echo "No Swift 6.0 Xcode on this runner has an iOS platform installed." >&2 + exit 1 # Only the library is built here. This job guards the minimum Swift # version the package claims to support, which is a promise about the # code consumers compile. The test target is exercised by the # current-swift job instead. The package is iOS only, so this cannot be - # a plain `swift build` against the macOS host, and the runner image - # carries no iOS 18 simulator runtime for Xcode 16.0, so it cannot be a - # simulator test either. + # a plain `swift build` against the macOS host, and no runner image + # carries an iOS 18.0 simulator runtime for these Xcodes, so it cannot + # be a simulator test either. - name: Build for iOS run: >- xcodebuild build @@ -55,7 +72,7 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Report toolchain run: |