Skip to content

Commit 317a665

Browse files
committed
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.
1 parent 9e30498 commit 317a665

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

packages/react-native/React-Core-prebuilt.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Pod::Spec.new do |s|
5252
# If we are passing a local tarball, we don't want to switch between Debug and Release
5353
if !ENV["RCT_TESTONLY_RNCORE_TARBALL_PATH"]
5454
script_phase = {
55-
:name => "[RNDeps] Replace React Native Core for the right configuration, if needed",
55+
:name => "[RNCore] Replace React Native Core for the right configuration, if needed",
5656
:execution_position => :before_compile,
5757
:script => <<-EOS
5858
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"

packages/react-native/scripts/replace-rncore-version.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,16 @@ function replaceRNCoreConfiguration(
6262
const tarballURLPath = `${podsRoot}/ReactNativeCore-artifacts/reactnative-core-${version.toLowerCase()}-${configuration.toLowerCase()}.tar.gz`;
6363

6464
const finalLocation = 'React-Core-prebuilt';
65-
console.log('Preparing the final location', finalLocation);
66-
fs.rmSync(finalLocation, {force: true, recursive: true});
67-
fs.mkdirSync(finalLocation, {recursive: true});
65+
66+
// Delete all directories - not files, since we want to keep the React-VFS.yaml file
67+
const dirs = fs
68+
.readdirSync(finalLocation, {withFileTypes: true})
69+
.filter(dirent => dirent.isDirectory());
70+
for (const dirent of dirs) {
71+
const dirPath = `${finalLocation}/${dirent.name}`;
72+
console.log('Removing directory', dirPath);
73+
fs.rmSync(dirPath, {force: true, recursive: true});
74+
}
6875

6976
console.log('Extracting the tarball', tarballURLPath);
7077
spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {

0 commit comments

Comments
 (0)