Skip to content

Commit 10c5192

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Fix unstable RCTAppDelegate podspec (#41009)
Summary: Pull Request resolved: #41009 This change should fix [#39971](#39971), computing the relative path from the App path to the pod installation root and using that instead of the absolute path to the `react-native.config.js` file ## Changelog [Internal] - Stabilize RCTAppDelegate podspec Reviewed By: cortinico Differential Revision: D50323710 fbshipit-source-id: e29e62228d08c752e822d7a9ab5b1a2b5dcd6eb4
1 parent 744fb4a commit 10c5192

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,19 @@ Pod::Spec.new do |s|
117117
s.dependency "React-debug"
118118
s.dependency "React-rendererdebug"
119119

120+
rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
121+
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
122+
123+
120124
s.script_phases = {
121125
:name => "Generate Legacy Components Interop",
122126
:script => "
123127
WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
124128
source $WITH_ENVIRONMENT
125-
${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{ENV['APP_PATH']} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
129+
${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{rel_path_from_pods_to_app} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
126130
",
127131
:execution_position => :before_compile,
128-
:input_files => ["#{ENV['APP_PATH']}/react-native.config.js"],
132+
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
129133
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
130134
}
131135
end

packages/react-native/scripts/codegen/generate-legacy-interop-components.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
const yargs = require('yargs');
1313
const fs = require('fs');
14+
const p = require('path');
1415

1516
const CONFIG_FILE_NAME = 'react-native.config.js';
1617
const PROJECT_FIELD = 'project';
@@ -92,7 +93,11 @@ function extractComponentsNames(reactNativeConfig) {
9293
}
9394

9495
function generateRCTLegacyInteropComponents() {
95-
const configFilePath = `${appRoot}/${CONFIG_FILE_NAME}`;
96+
const cwd = process.cwd();
97+
const configFilePath = p.join(cwd, appRoot, CONFIG_FILE_NAME);
98+
console.log(
99+
`Looking for a react-native.config.js file at ${configFilePath}...`,
100+
);
96101
let reactNativeConfig = null;
97102
try {
98103
reactNativeConfig = require(configFilePath);
@@ -106,7 +111,7 @@ function generateRCTLegacyInteropComponents() {
106111
console.log('Skip LegacyInterop generation');
107112
return;
108113
}
109-
114+
console.log(`Components found: ${componentNames}`);
110115
let componentsArray = componentNames.map(name => `\t\t\t@"${name}",`);
111116
// Remove the last comma
112117
if (componentsArray.length > 0) {
@@ -117,6 +122,7 @@ function generateRCTLegacyInteropComponents() {
117122

118123
const filePath = `${outputPath}/${OUTPUT_FILE_NAME}`;
119124
fs.writeFileSync(filePath, fileBody(componentsArray.join('\n')));
125+
console.log(`${filePath} updated!`);
120126
}
121127

122128
generateRCTLegacyInteropComponents();

0 commit comments

Comments
 (0)