Skip to content

Commit 62a2b38

Browse files
tjzelmeta-codesync[bot]
authored andcommitted
Fix debug Hermes being embedded in iOS Release builds after hermes-engine pod re-install (#57574)
Summary: The `hermes-engine` pod is always installed from the debug tarball; the debug/release selection is deferred to a build phase that runs `sdks/hermes-engine/utils/replace_hermes_version.js`. The script tracks which variant currently sits in `Pods/hermes-engine` through a `.last_build_configuration` marker at the Pods root and skips the swap when the marker matches the requested configuration. Whenever CocoaPods re-installs `hermes-engine`, the engine resets to the debug variant while the marker still claims `Release`. The next Release build takes the "Same config of the previous build" path and silently embeds the debug `hermesvm` into the Release app. I moved the marker inside `Pods/hermes-engine/` so a pod re-install destroys it together with the engine it describes and the next build re-runs the swap — the same pattern `replace-rncore-version.js` and `replace_dependencies_version.js` already use for their prebuilts. I also added some assertions. ## Changelog: [IOS] [FIXED] - Fix debug Hermes being silently embedded in Release builds after the hermes-engine pod is re-installed Pull Request resolved: #57574 Test Plan: Reproduced on `react-native@0.86.0` before the change: Release build, then `rm -rf ios/Pods/hermes-engine && pod install`, then Release build again — the app's embedded `hermesvm` is the debug binary (`nm -gU -arch arm64 hermesvm | grep -c CDPDebugAPI` prints 6, ~12.2 MB; the release binary prints 0, ~10.2 MB) while the marker says `Release`. Reviewed By: cortinico Differential Revision: D112308961 Pulled By: cipolleschi fbshipit-source-id: 2f4111ac7030fcedd888d91c6eb2dd034dc13c0d
1 parent dd5dc6b commit 62a2b38

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

packages/react-native/sdks/hermes-engine/utils/replace_hermes_version.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const {spawnSync} = require('child_process');
1414
const fs = require('fs');
1515
const yargs = require('yargs');
1616

17-
const LAST_BUILD_FILENAME = '.last_build_configuration';
17+
const LAST_BUILD_FILENAME = 'hermes-engine/.last_build_configuration';
1818

1919
function validateBuildConfiguration(configuration) {
2020
if (!['Debug', 'Release'].includes(configuration)) {
@@ -56,15 +56,29 @@ function shouldReplaceHermesConfiguration(configuration) {
5656
function replaceHermesConfiguration(configuration, version, podsRoot) {
5757
const tarballURLPath = `${podsRoot}/hermes-engine-artifacts/hermes-ios-${version.toLowerCase()}-${configuration.toLowerCase()}.tar.gz`;
5858

59+
if (!fs.existsSync(tarballURLPath)) {
60+
throw new Error(`Hermes tarball not found at ${tarballURLPath}`);
61+
}
62+
5963
const finalLocation = 'hermes-engine';
6064
console.log('Preparing the final location');
6165
fs.rmSync(finalLocation, {force: true, recursive: true});
6266
fs.mkdirSync(finalLocation, {recursive: true});
6367

6468
console.log('Extracting the tarball');
65-
spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {
66-
stdio: 'inherit',
67-
});
69+
const result = spawnSync(
70+
'tar',
71+
['-xf', tarballURLPath, '-C', finalLocation],
72+
{
73+
stdio: 'inherit',
74+
},
75+
);
76+
if (result.status !== 0) {
77+
fs.rmSync(finalLocation, {force: true, recursive: true});
78+
throw new Error(
79+
`Failed to extract ${tarballURLPath}: ${result.error?.message ?? `tar exited with status ${result.status}`}`,
80+
);
81+
}
6882
}
6983

7084
function updateLastBuildConfiguration(configuration) {

0 commit comments

Comments
 (0)