Skip to content

test(ios): automated Swift DCE verification for #if !DISABLE_* guards #211

Description

@kirich1409

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

  • New test module wiring xcconfig generation
  • Test compiles a Swift fixture with -O and asserts symbol stripping
  • CI job runs the test on the macOS runner (existing iOS build job already runs there)
  • Wiki page iOS — xcconfig DCE references the test
  • CHANGELOG.md [Unreleased] entry

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    gradle-pluginfeatured-gradle-plugin workiosiOS-specific worktestingTests and coverage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions