[No QA] Fix stale artifacts cache on iOS - #99185
Draft
mateuuszzzzz wants to merge 2 commits into
Draft
Conversation
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.
Explanation of Change
CocoaPods caches our prebuilt React Native artifacts by their source URL. That URL carries only the
plain react-native version, so a new patches version lands at the same path and CocoaPods keeps the
old extraction. It may not even re-read the podspec that downloads the tarballs. The app then
silently builds against a stale artifact.
Upstream RN has the same issue with Debug and Release artifacts (the cache does not distinguish
them either) and solves it outside CocoaPods. Its
[RNCore]build phase re-extracts the frameworkwhenever the
.last_build_configurationmarker does not match the current configuration. This PRextends that pattern to the patches version.
During
pod install, when the resolved version does not match the.artifacts-versionstamp ofthe tarballs in Pods, we drop CocoaPods' memoized podspec with
sandbox.remove_local_podspec. Thisforces a re-evaluation of the podspec, which re-runs podspec evaluation and the dSYM merge. The re-read
podspec is byte-identical, so
Podfile.lockis unaffected.During the build, a small prelude prepended into the
[RNCore]phase compares the tarballs' stampwith the extracted framework's stamp. On mismatch it writes
staleinto.last_build_configuration, and RN's own script re-extracts from the fresh tarballs right after.This reuses the upstream extraction machinery instead of duplicating it. It lives inside that phase
because CocoaPods sorts phases by name on save, so a separate phase could not run first.
The change covers patches version changes, the
RCT_SYMBOLICATE_PREBUILT_FRAMEWORKStoggle, warmsandboxes, removed Pods and interrupted builds. Debug and Release switching is untouched. When
nothing changed, both pieces are no-ops costing a couple of file reads.
Why this approach instead of a solution where we make CocoaPods differentiate between our patched versions? That would require significantly more effort and more patches to React Native internals. I’d prefer to keep our patched artifacts as close to upstream as possible to minimize the maintenance cost.
Fixed Issues
$ #99187
PROPOSAL:
MOBILE-EXPENSIFY: https://github.com/Expensify/Mobile-Expensify/pull/14066
Tests
Prerequisites: HybridApp iOS dev setup,
npm idone,gh auth login(Maven access), with successfulpod install+ build on this branch with the latest artifacts version (latestmainon both repos should be set).1. Note the current artifact version
cat Mobile-Expensify/ios/Pods/ReactNativeCore-artifacts/.artifacts-versionand note the version (e.g.0.86.0-5) — referred to as<current>below2. Force an older artifact version
scripts/artifacts-utils/lib/artifactsResolver.ts, add as the first line offindMatchingArtifactsVersion:3. Run pod install and verify it invalidates
cd Mobile-Expensify/ios && bundle exec pod install[PatchedArtifacts] Using patched react-native artifacts: react-hybrid:0.86.0-0[PatchedArtifacts] Artifacts changed to 0.86.0-0; the React-Core-prebuilt podspec will be re-evaluated.cat Pods/ReactNativeCore-artifacts/.artifacts-versionprints0.86.0-0git -C .. diff iOS/Podfile.lockshows no new changes4. Build and verify the extraction log
[PatchedArtifacts] Extracted prebuilt React Core is '<current>', tarballs are '0.86.0-0' — marking for re-extraction.Extracting the tarball to temp dir …cat Pods/React-Core-prebuilt/.patched-versionprints0.86.0-05. Verify the no-op fast path
marking for re-extractionline does NOT appear (silent = versions match)React-Core-prebuilt6. Revert and verify the round trip
artifactsResolver.tscd Mobile-Expensify/ios && bundle exec pod installand verify the output containsArtifacts changed to <current> …… is '0.86.0-0', tarballs are '<current>' — marking for re-extraction.followed by the extractioncat Pods/React-Core-prebuilt/.patched-versionis back to<current>Byte-level checks
dwarfdump --uuid Mobile-Expensify/ios/Pods/React-Core-prebuilt/React.xcframework/ios-arm64_x86_64-simulator/React.framework/Reactdwarfdump --uuid <DerivedData>/Build/Products/Debug-iphonesimulator/Expensify.app/Frameworks/React.framework/React0.86.0-0:6F445E91-…,0.86.0-5:7AFB6212-…)Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari