@@ -100,20 +100,28 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
100
100
function readGeneratedAutolinkingOutput (
101
101
baseOutputPath /*: string */ ,
102
102
) /*: $FlowFixMe */ {
103
- // NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
104
- const autolinkingGeneratedPath = path . resolve (
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)
105
107
baseOutputPath ,
106
- 'build/generated/autolinking/autolinking.json' ,
107
- ) ;
108
- if ( fs . existsSync ( autolinkingGeneratedPath ) ) {
109
- // $FlowFixMe[unsupported-syntax]
110
- return require ( autolinkingGeneratedPath ) ;
111
- } else {
112
- codegenLog (
113
- `Could not find generated autolinking output at: ${ autolinkingGeneratedPath } ` ,
114
- ) ;
115
- return null ;
108
+ ] ;
109
+ for ( const outputPathCandidate of outputPathCandidates ) {
110
+ if ( outputPathCandidate ) {
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
+ ) ;
122
+ }
116
123
}
124
+ return null ;
117
125
}
118
126
119
127
function readReactNativeConfig (
0 commit comments