Skip to content

Commit 90bc77f

Browse files
committed
Move RCT_SCRIPT_OUTPUT_DIR switching to generate-artifacts-executor/index.js
1 parent 449258e commit 90bc77f

File tree

2 files changed

+14
-25
lines changed
  • packages/react-native/scripts/codegen/generate-artifacts-executor

2 files changed

+14
-25
lines changed

packages/react-native/scripts/codegen/generate-artifacts-executor/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ function execute(
9090

9191
const reactNativeConfig = readReactNativeConfig(
9292
projectRoot,
93-
baseOutputPath,
93+
// NOTE: Used to load `build/generated/autolinking/autolinking.json` generated by `scripts/cocoapods/autolinking.rb`
94+
// If we have RCT_SCRIPT_OUTPUT_DIR (set in `react_native_pods_utils/script_phases.sh`, it takes precedence, otherwise
95+
// we search for the `autolinking.json` output in the `baseOutputPath`
96+
process.env.RCT_SCRIPT_OUTPUT_DIR || baseOutputPath,
9497
);
98+
9599
const codegenEnabledLibraries = findCodegenEnabledLibraries(
96100
pkgJson,
97101
projectRoot,

packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,20 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
100100
function readGeneratedAutolinkingOutput(
101101
baseOutputPath /*: string */,
102102
) /*: $FlowFixMe */ {
103-
// When run from Xcode, the generated file can be found via `RCT_SCRIPT_OUTPUT_DIR` consistently
104-
if (process.env.RCT_SCRIPT_OUTPUT_DIR) {
105-
const xcodeAutolinkingGeneratedPath = path.resolve(
106-
process.env.RCT_SCRIPT_OUTPUT_DIR,
107-
'build/generated/autolinking/autolinking.json',
108-
);
109-
if (fs.existsSync(xcodeAutolinkingGeneratedPath)) {
110-
// $FlowFixMe[unsupported-syntax]
111-
return require(xcodeAutolinkingGeneratedPath);
112-
}
113-
codegenLog(
114-
`Could not find generated autolinking output at: ${xcodeAutolinkingGeneratedPath}`,
115-
);
116-
}
117-
118-
// Otherwise, we expect to find it in the output path iself, when it's been generated in Cocoapods
119-
const podsAutolinkingGeneratedPath = path.resolve(
103+
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
104+
const autolinkingGeneratedPath = path.resolve(
120105
baseOutputPath,
121106
'build/generated/autolinking/autolinking.json',
122107
);
123-
if (fs.existsSync(podsAutolinkingGeneratedPath)) {
108+
if (fs.existsSync(autolinkingGeneratedPath)) {
124109
// $FlowFixMe[unsupported-syntax]
125-
return require(podsAutolinkingGeneratedPath);
110+
return require(autolinkingGeneratedPath);
111+
} else {
112+
codegenLog(
113+
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
114+
);
115+
return null;
126116
}
127-
codegenLog(
128-
`Could not find generated autolinking output at: ${podsAutolinkingGeneratedPath}`,
129-
);
130-
131-
return null;
132117
}
133118

134119
function readReactNativeConfig(

0 commit comments

Comments
 (0)