@@ -9,6 +9,7 @@ import * as projectServiceBaseLib from "./platform-project-service-base";
99import { PlistSession , Reporter } from "plist-merge-patch" ;
1010import { EOL } from "os" ;
1111import * as plist from "plist" ;
12+ import * as fastGlob from "fast-glob" ;
1213import { IOSProvisionService } from "./ios-provision-service" ;
1314import { IOSEntitlementsService } from "./ios-entitlements-service" ;
1415import { IOSBuildData } from "../data/build-data" ;
@@ -817,6 +818,21 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
817818 resourcesNativeCodePath ,
818819 projectData
819820 ) ;
821+
822+ const nativeSource = this . $projectConfigService . getValue (
823+ `${ this . _platformData . platformNameLowerCase } .NativeSource` ,
824+ [ ]
825+ ) ;
826+
827+ if ( nativeSource ?. length ) {
828+ for ( const source of nativeSource ) {
829+ await this . prepareNativeSourceCode (
830+ source . name ,
831+ source . path ,
832+ projectData
833+ ) ;
834+ }
835+ }
820836 }
821837
822838 this . $iOSWatchAppService . removeWatchApp ( { pbxProjPath } ) ;
@@ -1360,7 +1376,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
13601376 projectData : IProjectData
13611377 ) : Promise < void > {
13621378 const project = this . createPbxProj ( projectData ) ;
1363- const group = this . getRootGroup ( groupName , sourceFolderPath ) ;
1379+ const group = await this . getRootGroup ( groupName , sourceFolderPath ) ;
13641380 project . addPbxGroup ( group . files , group . name , group . path , null , {
13651381 isMain : true ,
13661382 filesRelativeToProject : true ,
@@ -1430,21 +1446,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
14301446 }
14311447 }
14321448
1433- private getRootGroup ( name : string , rootPath : string ) {
1449+ private async getRootGroup ( name : string , rootPath : string ) {
14341450 const filePathsArr : string [ ] = [ ] ;
14351451 const rootGroup : INativeSourceCodeGroup = {
14361452 name : name ,
14371453 files : filePathsArr ,
14381454 path : rootPath ,
14391455 } ;
14401456
1441- if ( this . $fs . exists ( rootPath ) ) {
1442- const stats = this . $fs . getFsStats ( rootPath ) ;
1443- if ( stats . isDirectory ( ) && ! this . $fs . isEmptyDir ( rootPath ) ) {
1444- this . $fs . readDirectory ( rootPath ) . forEach ( ( fileName ) => {
1445- const filePath = path . join ( rootGroup . path , fileName ) ;
1446- filePathsArr . push ( filePath ) ;
1447- } ) ;
1457+ if ( fastGlob . isDynamicPattern ( rootPath ) ) {
1458+ const projectRoot = this . $projectDataService . getProjectData ( ) . projectDir ;
1459+ const filePaths = await fastGlob ( rootPath ) ;
1460+ for ( const filePath of filePaths ) {
1461+ const sourceFilePath = path . normalize ( path . join ( projectRoot , filePath ) ) ;
1462+ filePathsArr . push ( sourceFilePath ) ;
1463+ }
1464+ } else {
1465+ if ( this . $fs . exists ( rootPath ) ) {
1466+ const stats = this . $fs . getFsStats ( rootPath ) ;
1467+ if ( stats . isDirectory ( ) && ! this . $fs . isEmptyDir ( rootPath ) ) {
1468+ this . $fs . readDirectory ( rootPath ) . forEach ( ( fileName ) => {
1469+ const filePath = path . join ( rootGroup . path , fileName ) ;
1470+ filePathsArr . push ( filePath ) ;
1471+ } ) ;
1472+ }
14481473 }
14491474 }
14501475
@@ -1499,13 +1524,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
14991524 }
15001525 }
15011526
1502- private removeNativeSourceCode (
1527+ private async removeNativeSourceCode (
15031528 pluginPlatformsFolderPath : string ,
15041529 pluginData : IPluginData ,
15051530 projectData : IProjectData
1506- ) : void {
1531+ ) {
15071532 const project = this . createPbxProj ( projectData ) ;
1508- const group = this . getRootGroup ( pluginData . name , pluginPlatformsFolderPath ) ;
1533+ const group = await this . getRootGroup (
1534+ pluginData . name ,
1535+ pluginPlatformsFolderPath
1536+ ) ;
15091537 project . removePbxGroup ( group . name , group . path ) ;
15101538 project . removeFromHeaderSearchPaths ( group . path ) ;
15111539 this . savePbxProj ( project , projectData ) ;
0 commit comments