Skip Swift Testing predicate tests on Xcode 14/15#6937
Merged
Conversation
Gate the RulesEngineInternal Swift Testing files behind `#if canImport(Testing)` so they compile only on the Xcode 16+ toolchain. The Xcode 14/15 CI jobs (run-test-ios-16, run-test-ios-15-and-14) lack the Testing module and were failing to compile. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Member
Author
|
@RCGitBot please test run-test-ios-15-and-14 run-test-ios-16 |
|
🚀 Triggered run-test-ios-15-and-14 run-test-ios-16 → Pipeline #38998 |
`#if canImport(Testing)` alone is insufficient on Xcode 14 (Swift 5.8): the pre-macro parser still reads `#expect`/`#require` in the inactive branch and fails with "unknown directive". Wrapping in `#if compiler(>=5.9)` makes Swift 5.8 skip the body without parsing it. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Member
Author
|
@RCGitBot please test run-test-ios-15-and-14 run-test-ios-16 |
|
🚀 Triggered run-test-ios-15-and-14 run-test-ios-16 → Pipeline #39003 |
rickvdl
approved these changes
Jun 8, 2026
rickvdl
left a comment
Member
There was a problem hiding this comment.
Nice! Great to be able to use Swift testing on these and more going forward :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The
run-test-ios-16(Xcode 15.4) andrun-test-ios-15-and-14(Xcode 14.3.1) CI jobs fail to compile the newRulesEngineInternaltests because Swift Testing'sTestingmodule only ships with the Xcode 16+ toolchain.Description
Gate the two Swift Testing files behind
#if compiler(>=5.9) && canImport(Testing)so they compile only where the toolchain provides it; the remaining XCTest tests still run everywhere.Notes
The outer
#if compiler(>=5.9)is required in addition tocanImport(Testing). With onlycanImport, Swift 5.8 (Xcode 14) still parses the inactive branch and rejects the#expect/#requiremacros as unknown directives. The version check makes the pre-macro compiler skip the body without parsing it.Note
Low Risk
Test-only conditional compilation with no production or runtime behavior changes.
Overview
Wraps
PredicateConformanceRunner.swiftandPredicateFixtureTests.swiftin#if compiler(>=5.9)and#if canImport(Testing)…#endifso Swift Testing code (including#expect/#require) is only compiled on Xcode 16+ toolchains.Older CI (Xcode 14/15) no longer fails on those files; XCTest tests in the same target are unchanged and still build and run everywhere.
Reviewed by Cursor Bugbot for commit f4380de. Bugbot is set up for automated code reviews on this repo. Configure here.