fix(ci): pin Tier-3 iOS cache key to Xcode version#631
Merged
Conversation
The Tier-3 `Cache iOS DerivedData + Pods` step keyed only on
`runner.os + lock files`. When the macOS-latest runner image upgrades
Xcode (and the iOS SDK with it), the cached `SwiftShims-*.pcm` module
files reference SDK `module.modulemap` mtimes from the previous
toolchain. Swift then rejects the cached modules and the
`Build iOS simulator app` step fails with:
File '...iPhoneSimulator18.5.sdk/usr/lib/swift/shims/module.modulemap'
has been modified since the module file '...SwiftShims-*.pcm' was
built: mtime changed (was X, now Y)
Resolving the active `xcodebuild -version` into the cache key (and the
restore-keys fallback) invalidates the cache exactly when the SDK rolls,
so cache-hits only restore objects that were built against the current
toolchain.
This was referenced Jun 1, 2026
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.
Problem
The Tier-3 `Build iOS simulator app` step failed on PR #626 with:
```
Swift Compiler Error (Xcode): File '/Applications/Xcode_16.4.app/.../iPhoneSimulator18.5.sdk/usr/lib/swift/shims/module.modulemap'
has been modified since the module file '.../ModuleCache.noindex/.../SwiftShims-2ZSRUUIS75TOI.pcm' was built:
mtime changed (was 1779274009, now 1779861061)
```
The cached `SwiftShims-*.pcm` referenced a previous SDK's `module.modulemap` mtime — its own `module.modulemap` had been rewritten by the runner image's Xcode upgrade between two macOS-latest runs.
Root cause
`Cache iOS DerivedData + Pods` keyed only on `runner.os + lock files`. `runner.os` is just `"macOS"` regardless of the runtime Xcode/SDK version, so a cache restored across an Xcode bump produces `.pcm` files that point at SDK file mtimes from the previous toolchain. Swift refuses to use them and the build fails.
Fix
Resolve `xcodebuild -version` at runtime and inject it into both the cache key and the restore-keys fallback. The cache now invalidates exactly when the active Xcode rolls, so a hit can only restore objects that were built against the current toolchain.
The version string is normalised (`tr '\n' '-' | sed 's/[^A-Za-z0-9.-]//g; s/-$//'`) so `Xcode 16.4 / Build version 16F6` becomes a safe cache-key fragment like `Xcode-16.4-Build-version-16F6`.
Validation plan