Skip to content

🐛 - zstandardios Remove synced zstd script phase races the compiler intermittent Build input file cannot be found failures #143

Description

@cecharlier

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Zstandard, Zstandard iOS

Which platforms are affected?

iOS

Description

ios/zstandard_ios.podspec (v1.5.0) defines two build-time script phases:

  1. Sync zstd — copies the zstd C sources into Classes/zstd/ (:execution_position => :before_headers)
  2. Remove synced zstd — rm -rf "${PODS_TARGET_SRCROOT}/Classes/zstd" with :execution_position => :any

Because the removal phase uses :any and declares no input/output files, Xcode's parallel build system is free to schedule it before or during compilation of the very sources it deletes.

Expected: iOS builds succeed deterministically.

Actual: builds fail intermittently with Build input file cannot be found for zstd C sources (compress/zstdmt_compress.c, legacy/zstd_v06.c, legacy/zstd_v07.c), then succeed on retry with no changes, then fail again. Xcode also warns the phase "will be run during every build because it does not specify any outputs."

Side effect worth flagging: PODS_TARGET_SRCROOT resolves (through Flutter's .symlinks) into the user's pub cache, so this phase deletes files from ~/.pub-cache/hosted/pub.dev/zstandard_ios-1.5.0/ — mutating the shared package cache on every build.

Suggested fix: delete the Remove synced zstd script phase. The Sync zstd phase plus the prepare_command already guarantee the sources exist, and consumers never need them removed at build time. I verified locally that removing the phase and re-running pod install makes builds deterministic.

Reproducing the issue

  1. Add zstandard: 1.5.0 to a Flutter app.
  2. Run flutter build ios --simulator --debug repeatedly (a clean DerivedData makes the failure more likely).
  3. Builds alternate between success and "Build input file cannot be found" for zstd C sources, with no code changes between runs.

Flutter Version

3.44.5

Relevant Log Output

Error (Xcode): Build input file cannot be found:
'/Users/<user>/.pub-cache/hosted/pub.dev/zstandard_ios-1.5.0/ios/Classes/zstd/compress/zstdmt_compress.c'.
Did you forget to declare this file as an output of a script phase or custom build rule which produces it?

Also seen for:
.../zstandard_ios-1.5.0/ios/Classes/zstd/legacy/zstd_v06.c
.../zstandard_ios-1.5.0/ios/Classes/zstd/legacy/zstd_v07.c

Xcode warning:
Run script build phase '[CP-User] Remove synced zstd' will be run during every build
because it does not specify any outputs.

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

This looks related to the script phases introduced for #127 ("Apple scripts out of packages") — the sync phase works, but the removal phase's :execution_position => :any lets Xcode schedule it against the compiler. SPM support is already tracked in #141, so not raising that here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions