Repository navigation
Add --mergeable option to the iOS prebuild scripts - #60328
Merged
Merged
Conversation
The iOS prebuild scripts cannot build React and ReactNativeDependencies as mergeable frameworks, which Xcode can merge into an app executable. --mergeable adds MERGEABLE_LIBRARY (for dynamic libraries only) to the Release xcodebuild command in both scripts. Debug builds and builds without the option are unchanged.
cipolleschi
approved these changes
Nov 27, 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.
Summary:
React Native's iOS prebuild scripts cannot build React and ReactNativeDependencies as mergeable frameworks. Xcode can merge a mergeable framework into the app executable, where the linker can remove unused code. Today the scripts only build plain dynamic frameworks.
This PR adds an opt-in
--mergeableoption to both scripts:packages/react-native/scripts/ios-prebuild(React) andscripts/releases/prepare-ios-prebuilds.js(ReactNativeDependencies) accept--mergeable.xcodebuildcommand gets'MERGEABLE_LIBRARY=$(MERGEABLE_LIBRARY_$(MACH_O_TYPE))' MERGEABLE_LIBRARY_mh_dylib=YES. This marks only dynamic libraries as mergeable. A plainMERGEABLE_LIBRARY=YESalso applies to the static dependencies and breaks their link.__docs__/README.mdfiles document the option.Nothing builds or ships mergeable frameworks by default. Publishing them, and letting apps opt in through SwiftPM or CocoaPods, are separate follow-up changes.
Changelog:
[INTERNAL] [ADDED] - Add a
--mergeableoption to the iOS prebuild scripts to build mergeable Release frameworksTest Plan:
Unit tests (new tests for the build command and option parsing):
13 suites, 114 tests pass. Before the change, the 6 new tests failed because the option was missing.
Release build with the option, device and simulator:
Both builds succeed. Every slice of React.xcframework and ReactNativeDependencies.xcframework carries the
LC_ATOM_INFOload command that marks a mergeable binary (otool -l <binary> | grep -c LC_ATOM_INFOprints 1 forios-arm64and 2 forios-arm64_x86_64-simulator). The 0.88.1 release frameworks print 0.yarn flow-check, ESLint and Prettier pass on the changed files. Not run: Mac Catalyst slices.