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], {