Skip to content

Strip local symbols from Release prebuilt iOS frameworks - #60259

Open
chrfalch wants to merge 1 commit into
mainfrom
ios-strip-prebuilt-frameworks
Open

chrfalch wants to merge 1 commit into
mainfrom
ios-strip-prebuilt-frameworks

Conversation

@chrfalch

Copy link
Copy Markdown
Collaborator

Summary:

The prebuilt iOS frameworks React and ReactNativeDependencies ship with all their local symbols. No build step removes them:

  • The prebuild scripts make a dSYM (debug symbol file) for each framework, but never strip the binary.
  • The SwiftPM embed phase copies the frameworks with rsync. The CocoaPods embed script only removes unused architectures.
  • App Store export strips only the Swift runtime libraries.

So every app that uses the prebuilt frameworks carries the extra size.

This PR strips the Release frameworks when the artifact is built. One change covers SwiftPM apps and CocoaPods apps.

  1. For the Release flavor, the prebuild scripts run xcrun strip -x on each slice's framework binary. strip -x removes local symbols only, so exported symbols stay. Debug builds are not stripped, so a debugger still shows the symbols without a dSYM download.
  2. The strip runs only after the slice's dSYM is copied to the Symbols folder. The dSYM comes from the unstripped binary and keeps the same UUID, so crash symbolication keeps working. A missing dSYM now stops the build with a clear error.
  3. If a framework was code-signed before the strip, the scripts sign it again ad hoc. Xcode signs simulator slices when it builds them, and the strip makes that signature invalid. Device slices were unsigned before this change and stay unsigned.
  4. For React, the strip and the new signature come after the header step. That step writes Headers/ and Modules/ into each React.framework.
  5. prebuild-ios-dependencies.yml now passes -r ${{ matrix.flavor }} to the ReactNativeDependencies compose step. Without the flag, that step always used Debug and never reached the strip. The new helper strip-symbols.js is also added to that workflow's cache key.

Not in this PR: hermesvm.xcframework. It is built outside this repository.

Changelog:

[IOS] [CHANGED] - Strip local symbols from the Release prebuilt React and ReactNativeDependencies frameworks

Test Plan:

Unit tests:

yarn jest --no-cache -i packages/react-native/scripts/ios-prebuild scripts/releases/ios-prebuild

Result: 12 suites, 116 of 116 tests passed. The new tests failed before the code change: strip after the dSYM copy, Debug not stripped, missing dSYM throws, re-sign only when signed before, and strip after the header step.

yarn flow-check and eslint --max-warnings 0 on the changed files: no errors.

Real Release build, on this branch:

node scripts/releases/prepare-ios-prebuilds.js -b -p ios ios-simulator -r Release
node scripts/releases/prepare-ios-prebuilds.js -c -r Release
cd packages/react-native
node scripts/ios-prebuild.js -s -f Release
node scripts/ios-prebuild.js -b -f Release -p ios
node scripts/ios-prebuild.js -b -f Release -p ios-simulator
node scripts/ios-prebuild.js -c -f Release
Binary (ios-arm64 slice) Before After
React 10,364,152 B 6,565,240 B
ReactNativeDependencies 1,174,848 B 873,296 B

Checks on each slice:

  • dwarfdump --uuid gives the same UUID for the stripped binary and its dSYM, on the device slice and on both simulator architectures.
  • codesign --verify --deep --strict passes on the React and ReactNativeDependencies simulator frameworks. Device frameworks stay unsigned, as before.
  • nm -gU gives the same number of exported symbols before and after the strip.

Not run: a CI build with a real signing identity.

The prebuilt React and ReactNativeDependencies frameworks shipped with
all local symbols. Neither the SwiftPM embed phase nor the CocoaPods
embed script strips them, so apps carried the extra size into the
App Store.

For the Release flavor, the prebuild scripts now run `strip -x` on each
slice's framework binary after its dSYM has been copied, so crash
symbolication keeps working. A slice that was signed before the strip
is re-signed ad hoc. For React, this runs after the framework headers
are written. CI now passes the flavor to the ReactNativeDependencies
compose step, which defaulted to Debug.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 24, 2026
@facebook-github-tools facebook-github-tools Bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 5265764669ad.

ios: no capture

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant