@@ -100,27 +100,34 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
100
100
function readGeneratedAutolinkingOutput (
101
101
baseOutputPath /*: string */ ,
102
102
) /*: $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 ) ;
122
112
}
113
+ codegenLog (
114
+ `Could not find generated autolinking output at: ${ xcodeAutolinkingGeneratedPath } ` ,
115
+ ) ;
123
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 (
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
+
124
131
return null ;
125
132
}
126
133
0 commit comments