Skip to content

Commit 11e257c

Browse files
chrfalchmeta-codesync[bot]
authored andcommitted
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 #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: #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
1 parent 141e021 commit 11e257c

2 files changed

Lines changed: 13 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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,18 @@ 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 direntName =
72+
typeof dirent.name === 'string' ? dirent.name : dirent.name.toString();
73+
const dirPath = `${finalLocation}/${direntName}`;
74+
console.log('Removing directory', dirPath);
75+
fs.rmSync(dirPath, {force: true, recursive: true});
76+
}
6877

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

0 commit comments

Comments
 (0)