Goal
Add an automated test that proves the Swift compiler eliminates code guarded by #if !DISABLE_* from release binaries, mirroring featured-shrinker-tests for Android R8.
Context
The Gradle plugin generates FeatureFlags.generated.xcconfig with SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) DISABLE_<FLAG_KEY> for each local flag whose defaultValue = false:
Today there is no automated verification that Swift DCE actually strips the guarded branches from the release binary — the equivalent of featured-shrinker-tests/src/test/kotlin/dev/androidbroadcast/featured/shrinker/R8BooleanFlagEliminationTest.kt is missing for iOS.
Approach
- Add a
featured-swift-dce-tests Gradle module (skipped on non-macOS hosts).
- Generate xcconfig via the existing plugin task.
- Compile a small Swift fixture (
swiftc -O -D DISABLE_X) — bypass full Xcode to keep the test fast.
- Read symbols from the resulting object/binary (
nm or swift demangle) and assert that symbols from the disabled branch are absent.
- Verify the opposite case (no
-D DISABLE_X) keeps the symbol present.
Definition of Done
Related
Goal
Add an automated test that proves the Swift compiler eliminates code guarded by
#if !DISABLE_*from release binaries, mirroringfeatured-shrinker-testsfor Android R8.Context
The Gradle plugin generates
FeatureFlags.generated.xcconfigwithSWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) DISABLE_<FLAG_KEY>for each local flag whosedefaultValue = false:build-logic/featured-gradle-plugin/src/main/kotlin/dev/androidbroadcast/featured/gradle/XcconfigGenerator.ktiosApp/iosApp/ContentView.swift(#if !DISABLE_*guards)#ifpattern doc).Today there is no automated verification that Swift DCE actually strips the guarded branches from the release binary — the equivalent of
featured-shrinker-tests/src/test/kotlin/dev/androidbroadcast/featured/shrinker/R8BooleanFlagEliminationTest.ktis missing for iOS.Approach
featured-swift-dce-testsGradle module (skipped on non-macOS hosts).swiftc -O -D DISABLE_X) — bypass full Xcode to keep the test fast.nmorswift demangle) and assert that symbols from the disabled branch are absent.-D DISABLE_X) keeps the symbol present.Definition of Done
-Oand asserts symbol strippingiOS — xcconfig DCEreferences the testCHANGELOG.md[Unreleased]entryRelated