Repository navigation
Prove generated DISABLE_ conditions strip guarded Swift symbols - #313
Merged
Merged
Conversation
Issue 211 had no check that a symbol behind #if !DISABLE_* is absent when generateXcconfig emits the matching condition. Add featured-swift-dce-tests and run it on the macOS CI job. A missing or mismatched condition fails before compilation. Hosts without swiftc skip; -PrequireSwiftDce=true does not.
There was a problem hiding this comment.
🟡 Changes recommended
Because swiftc and nm are not task inputs, installing Swift or changing toolchains can leave the test incorrectly up-to-date or reuse a stale cached success.
1 open issue
What changed in this PR
Adds automated verification that the Featured plugin’s generated Swift compilation conditions remove guarded symbols, complementing the existing Android R8 checks.
Changes:
- Adds a test module that consumes generated xcconfig conditions.
- Compiles a Swift fixture with and without those conditions and checks symbol absence and presence.
- Runs the verification in macOS CI with missing Swift tooling treated as a failure.
| File | Description |
|---|---|
settings.gradle.kts |
Registers the Swift verification module. |
featured-swift-dce-tests/src/test/swift/GuardedCheckout.swift |
Adds a conditionally compiled symbol fixture. |
featured-swift-dce-tests/src/test/kotlin/dev/androidbroadcast/featured/swift/SwiftFlagStrippingTest.kt |
Validates generated conditions and checks compiled symbols. |
featured-swift-dce-tests/build.gradle.kts |
Wires flag generation, dependencies, and test inputs. |
.github/workflows/ci.yml |
Requires Swift verification in the macOS job. |
Review effort: Balanced
| inputs.file(swiftDceTestArguments.xcconfig) | ||
| inputs.file(swiftDceTestArguments.fixture) | ||
| inputs.property("requireSwiftDce", swiftDceTestArguments.requireSwiftDce) | ||
| jvmArgumentProviders.add(swiftDceTestArguments) |
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.

Closes #211
Type of change
Checklist
./gradlew spotlessCheckpassesNotes for reviewers
The generator already emits
DISABLE_<FLAG>for a local boolean whose default is false. Nothing compiled that condition and checked the guarded symbol was gone. This adds that check. Plugin behavior,iosApp, remote-flag filtering, the wiki, andCHANGELOG.mdare unchanged. Issue 211 can be closed from the fixture evidence.:featured-swift-dce-testsappliesdev.androidbroadcast.featuredand declaresboolean("new_checkout", default = false).tasks.testdepends ongenerateXcconfigand readsbuild/featured/FeatureFlags.generated.xcconfig. The test fails if that file is missing or blank, or if theDISABLE_*tokens (ignoring$(inherited)) are not exactlyDISABLE_NEW_CHECKOUT. It then compilesGuardedCheckoutSymbolwithswiftc -c -Oand only those parsed tokens as-D, and checksnm -g. The same file compiled without those tokens must still contain the symbol. A hand-written-Dis not a substitute.The module depends on
:corebecause the plugin auto-wires generatedConfigParamsources into the Kotlin/JVM compilation, and those sources import the Featured runtime.Hosts without
swiftcskip the compile. A skip is not a pass. The macOSbuild-iosjob runs./gradlew :featured-swift-dce-tests:test -PrequireSwiftDce=true, so a missing toolchain fails CI. Ubuntu./gradlew testmay skip this test; a green Ubuntu job is not this proof.Verified locally on Apple Swift 6.2 and
/usr/bin/nm:default = falseproducesSWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) DISABLE_NEW_CHECKOUT, and the test passes with the compile not skipped.default = truewrites a blank xcconfig and the test fails before compilation.GuardedCheckoutSymbolafter compilation with the generated-D, and the test fails.swiftcabsent, the test skips. With-PrequireSwiftDce=true, that skip fails.No SDK, simulator, or toolchain was installed.