From 317a665dd3181a359b1976c50aedb37767dcbca5 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Tue, 3 Feb 2026 13:15:20 +0100 Subject: [PATCH 1/2] fix(precompile) fixed replace script deleting the react-vfs.yaml file on iOS 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. --- packages/react-native/React-Core-prebuilt.podspec | 2 +- .../react-native/scripts/replace-rncore-version.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/react-native/React-Core-prebuilt.podspec b/packages/react-native/React-Core-prebuilt.podspec index 4892ce8ab278..98aa6a09b1df 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 1385b71ffb4a..6b06de7a88e4 100644 --- a/packages/react-native/scripts/replace-rncore-version.js +++ b/packages/react-native/scripts/replace-rncore-version.js @@ -62,9 +62,16 @@ 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 dirPath = `${finalLocation}/${dirent.name}`; + console.log('Removing directory', dirPath); + fs.rmSync(dirPath, {force: true, recursive: true}); + } console.log('Extracting the tarball', tarballURLPath); spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], { From 24f388016f4027726468fa8b352a3364b3f70613 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Tue, 3 Feb 2026 14:40:52 +0100 Subject: [PATCH 2/2] fix(flow-error) fixed flow error Reading dirent.name failed - let's fix it! --- packages/react-native/scripts/replace-rncore-version.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/scripts/replace-rncore-version.js b/packages/react-native/scripts/replace-rncore-version.js index 6b06de7a88e4..b2bcad5d9141 100644 --- a/packages/react-native/scripts/replace-rncore-version.js +++ b/packages/react-native/scripts/replace-rncore-version.js @@ -68,7 +68,9 @@ function replaceRNCoreConfiguration( .readdirSync(finalLocation, {withFileTypes: true}) .filter(dirent => dirent.isDirectory()); for (const dirent of dirs) { - const dirPath = `${finalLocation}/${dirent.name}`; + 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}); }