@@ -765,10 +765,37 @@ export default TurboModuleRegistry.getEnforcing<Spec>('${moduleName}');
765765 private async generateStubFiles ( ) : Promise < void > {
766766 this . verboseMessage ( 'Generating C++ stub files...' ) ;
767767
768- const codegenDir = path . join ( this . root , 'codegen' ) ;
768+ // Look for codegen directory in multiple possible locations
769+ let codegenDir = path . join ( this . root , 'codegen' ) ;
770+ let codegenLocation = 'root' ;
771+
772+ if ( ! ( await fs . exists ( codegenDir ) ) ) {
773+ // Try looking in windows directory
774+ const windowsDir = path . join ( this . root , 'windows' ) ;
775+ if ( await fs . exists ( windowsDir ) ) {
776+ const windowsSubdirs = await fs . readdir ( windowsDir ) ;
777+ // Look for subdirectories that might contain codegen
778+ for ( const subdir of windowsSubdirs ) {
779+ const subdirPath = path . join ( windowsDir , subdir ) ;
780+ const stats = await fs . stat ( subdirPath ) ;
781+ if ( stats . isDirectory ( ) ) {
782+ const possibleCodegenDir = path . join ( subdirPath , 'codegen' ) ;
783+ if ( await fs . exists ( possibleCodegenDir ) ) {
784+ codegenDir = possibleCodegenDir ;
785+ codegenLocation = `windows/${ subdir } ` ;
786+ this . verboseMessage ( `Found codegen directory at: ${ codegenDir } ` ) ;
787+ break ;
788+ }
789+ }
790+ }
791+ }
792+ } else {
793+ this . verboseMessage ( `Found codegen directory at: ${ codegenDir } ` ) ;
794+ }
795+
769796 if ( ! ( await fs . exists ( codegenDir ) ) ) {
770797 this . verboseMessage (
771- 'No codegen directory found, skipping stub generation' ,
798+ 'No codegen directory found in root or windows subdirectories , skipping stub generation' ,
772799 ) ;
773800 return ;
774801 }
@@ -783,7 +810,7 @@ export default TurboModuleRegistry.getEnforcing<Spec>('${moduleName}');
783810 return ;
784811 }
785812
786- this . verboseMessage ( `Found ${ specFiles . length } codegen spec file(s): ${ specFiles . join ( ', ' ) } ` ) ;
813+ this . verboseMessage ( `Found ${ specFiles . length } codegen spec file(s) in ${ codegenLocation } : ${ specFiles . join ( ', ' ) } ` ) ;
787814
788815 for ( const specFile of specFiles ) {
789816 const specName = specFile . replace ( 'Spec.g.h' , '' ) ;
@@ -796,7 +823,7 @@ export default TurboModuleRegistry.getEnforcing<Spec>('${moduleName}');
796823 }
797824
798825 // Parse method signatures from codegen files first, then fallback to TypeScript spec files
799- const methods = await this . parseSpecFileForMethods ( specName ) ;
826+ const methods = await this . parseSpecFileForMethods ( specName , codegenDir ) ;
800827
801828 if ( methods . length === 0 ) {
802829 this . verboseMessage (
@@ -828,12 +855,13 @@ export default TurboModuleRegistry.getEnforcing<Spec>('${moduleName}');
828855
829856 private async parseSpecFileForMethods (
830857 moduleName : string ,
858+ codegenDir ?: string ,
831859 ) : Promise < MethodSignature [ ] > {
832860 try {
833861 // First, try to read from codegen C++ header files
834- const codegenDir = path . join ( this . root , 'codegen' ) ;
835- if ( await fs . exists ( codegenDir ) ) {
836- const methods = await this . parseCodegenHeaderFiles ( codegenDir , moduleName ) ;
862+ const actualCodegenDir = codegenDir || path . join ( this . root , 'codegen' ) ;
863+ if ( await fs . exists ( actualCodegenDir ) ) {
864+ const methods = await this . parseCodegenHeaderFiles ( actualCodegenDir , moduleName ) ;
837865 if ( methods . length > 0 ) {
838866 this . verboseMessage (
839867 `Extracted ${ methods . length } methods from codegen files: ${ methods
0 commit comments