From 11e257cec09d1e69e7261fd769ad0f0e4007e09e Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Thu, 5 Feb 2026 08:08:33 -0800 Subject: [PATCH] fix(precompile) fixed replace script deleting the react-vfs.yaml file on iOS (#55394) Summary: When the user switches from Debug -> Release we'll replace the React-Core-prebuilt XCFramework. Previously we nuked the ios/Pods/React-Core-prebuilt folder - but after we added support for VFS overlays to honor header files in the XCFramework this folder will also contain the VFS-file (React-VFS.yaml) which shouldn't be removed. Removing this file causes an error when building. This commit fixes this by deleting all directories inside the Pods/React-Core-prebuilt folder, leaving any files (React-VFS.yaml) untouched. I've tested this in a new project and in RN-Tester and it works. I measured the size of the XCFramework when switching between Debug/Release to confirm that the switch still works. I also changed the name of the podspec script since it showd RNDeps and not RNCore. This issue was introduced in https://github.com/facebook/react-native/issues/54842 and not yet released in any version. ## Changelog: [IOS] [FIXED] - Fixed replace script deleting the react-vfs.yaml file on iOS Pull Request resolved: https://github.com/facebook/react-native/pull/55394 Test Plan: Run RN-Tester with precompiled binaries and build both release and debug. Reviewed By: cortinico Differential Revision: D92159099 Pulled By: cipolleschi fbshipit-source-id: 3ae7bd03431b225672ac4b4f7b91e6ef44765019 --- packages/react-native/React-Core-prebuilt.podspec | 2 +- .../scripts/replace-rncore-version.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/react-native/React-Core-prebuilt.podspec b/packages/react-native/React-Core-prebuilt.podspec index 4892ce8ab27..98aa6a09b1d 100644 --- a/packages/react-native/React-Core-prebuilt.podspec +++ b/packages/react-native/React-Core-prebuilt.podspec @@ -52,7 +52,7 @@ Pod::Spec.new do |s| # If we are passing a local tarball, we don't want to switch between Debug and Release if !ENV["RCT_TESTONLY_RNCORE_TARBALL_PATH"] script_phase = { - :name => "[RNDeps] Replace React Native Core for the right configuration, if needed", + :name => "[RNCore] Replace React Native Core for the right configuration, if needed", :execution_position => :before_compile, :script => <<-EOS . "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" diff --git a/packages/react-native/scripts/replace-rncore-version.js b/packages/react-native/scripts/replace-rncore-version.js index 1385b71ffb4..b2bcad5d914 100644 --- a/packages/react-native/scripts/replace-rncore-version.js +++ b/packages/react-native/scripts/replace-rncore-version.js @@ -62,9 +62,18 @@ function replaceRNCoreConfiguration( const tarballURLPath = `${podsRoot}/ReactNativeCore-artifacts/reactnative-core-${version.toLowerCase()}-${configuration.toLowerCase()}.tar.gz`; const finalLocation = 'React-Core-prebuilt'; - console.log('Preparing the final location', finalLocation); - fs.rmSync(finalLocation, {force: true, recursive: true}); - fs.mkdirSync(finalLocation, {recursive: true}); + + // Delete all directories - not files, since we want to keep the React-VFS.yaml file + const dirs = fs + .readdirSync(finalLocation, {withFileTypes: true}) + .filter(dirent => dirent.isDirectory()); + for (const dirent of dirs) { + const direntName = + typeof dirent.name === 'string' ? dirent.name : dirent.name.toString(); + const dirPath = `${finalLocation}/${direntName}`; + console.log('Removing directory', dirPath); + fs.rmSync(dirPath, {force: true, recursive: true}); + } console.log('Extracting the tarball', tarballURLPath); spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {