Skip to content

Commit 5858fd7

Browse files
cipolleschifortmarek
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 2f08813 commit 5858fd7

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
@@ -96,15 +96,19 @@ Pod::Spec.new do |s|
9696
s.dependency "React-utils"
9797
s.dependency "React-debug"
9898

99+
rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
100+
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
101+
102+
99103
s.script_phases = {
100104
:name => "Generate Legacy Components Interop",
101105
:script => "
102106
WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
103107
source $WITH_ENVIRONMENT
104-
${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{ENV['APP_PATH']} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
108+
${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
105109
",
106110
:execution_position => :before_compile,
107-
:input_files => ["#{ENV['APP_PATH']}/react-native.config.js"],
111+
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
108112
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
109113
}
110114
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';
@@ -93,7 +94,11 @@ function extractComponentsNames(reactNativeConfig) {
9394
}
9495

9596
function generateRCTLegacyInteropComponents() {
96-
const configFilePath = `${appRoot}/${CONFIG_FILE_NAME}`;
97+
const cwd = process.cwd();
98+
const configFilePath = p.join(cwd, appRoot, CONFIG_FILE_NAME);
99+
console.log(
100+
`Looking for a react-native.config.js file at ${configFilePath}...`,
101+
);
97102
let reactNativeConfig = null;
98103
try {
99104
reactNativeConfig = require(configFilePath);
@@ -107,7 +112,7 @@ function generateRCTLegacyInteropComponents() {
107112
console.log('Skip LegacyInterop generation');
108113
return;
109114
}
110-
115+
console.log(`Components found: ${componentNames}`);
111116
let componentsArray = componentNames.map(name => `\t\t\t@"${name}",`);
112117
// Remove the last comma
113118
if (componentsArray.length > 0) {
@@ -118,6 +123,7 @@ function generateRCTLegacyInteropComponents() {
118123

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

123129
generateRCTLegacyInteropComponents();

0 commit comments

Comments
 (0)