Skip to content

Commit c7af004

Browse files
committed
Add comments and separate pods/xcode autolinking.json loading
1 parent b464256 commit c7af004

File tree

1 file changed

+26
-19
lines changed
  • packages/react-native/scripts/codegen/generate-artifacts-executor

1 file changed

+26
-19
lines changed

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

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,34 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
100100
function readGeneratedAutolinkingOutput(
101101
baseOutputPath /*: string */,
102102
) /*: $FlowFixMe */ {
103-
const outputPathCandidates = [
104-
// The `outputDir` may not be set correctly if it's set to the a temporary output directory
105-
process.env.RCT_SCRIPT_OUTPUT_DIR,
106-
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
107-
baseOutputPath,
108-
];
109-
for (const outputPathCandidate of outputPathCandidates) {
110-
if (outputPathCandidate != null && outputPathCandidate.length > 0) {
111-
const autolinkingGeneratedPath = path.resolve(
112-
outputPathCandidate,
113-
'build/generated/autolinking/autolinking.json',
114-
);
115-
if (fs.existsSync(autolinkingGeneratedPath)) {
116-
// $FlowFixMe[unsupported-syntax]
117-
return require(autolinkingGeneratedPath);
118-
}
119-
codegenLog(
120-
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
121-
);
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);
122112
}
113+
codegenLog(
114+
`Could not find generated autolinking output at: ${xcodeAutolinkingGeneratedPath}`,
115+
);
123116
}
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(
120+
baseOutputPath,
121+
'build/generated/autolinking/autolinking.json',
122+
);
123+
if (fs.existsSync(podsAutolinkingGeneratedPath)) {
124+
// $FlowFixMe[unsupported-syntax]
125+
return require(podsAutolinkingGeneratedPath);
126+
}
127+
codegenLog(
128+
`Could not find generated autolinking output at: ${podsAutolinkingGeneratedPath}`,
129+
);
130+
124131
return null;
125132
}
126133

0 commit comments

Comments
 (0)