@@ -1532,7 +1532,11 @@ export class IOSProjectService
15321532 projectData : IProjectData ,
15331533 ) : Promise < void > {
15341534 const project = this . createPbxProj ( projectData ) ;
1535- const group = await this . getRootGroup ( groupName , sourceFolderPath ) ;
1535+ const group = await this . getRootGroup (
1536+ groupName ,
1537+ sourceFolderPath ,
1538+ projectData . projectDir ,
1539+ ) ;
15361540 // pin the sources to the main app target: without an explicit target the
15371541 // underlying xcode lib picks whichever "Sources" build phase it finds
15381542 // first, which can be an extension target (e.g. a widget) once one
@@ -1597,7 +1601,11 @@ export class IOSProjectService
15971601 }
15981602 }
15991603
1600- private async getRootGroup ( name : string , rootPath : string ) {
1604+ private async getRootGroup (
1605+ name : string ,
1606+ rootPath : string ,
1607+ projectRoot : string ,
1608+ ) {
16011609 const filePathsArr : string [ ] = [ ] ;
16021610 const rootGroup : INativeSourceCodeGroup = {
16031611 name : name ,
@@ -1606,17 +1614,19 @@ export class IOSProjectService
16061614 } ;
16071615
16081616 if ( fastGlob . isDynamicPattern ( rootPath ) ) {
1609- const projectRoot = this . $projectDataService . getProjectData ( ) . projectDir ;
1610- const filePaths = await fastGlob ( rootPath ) ;
1617+ // Relative to the project: --path can run the CLI from anywhere.
1618+ const filePaths = await fastGlob ( rootPath , { cwd : projectRoot } ) ;
16111619 for ( const filePath of filePaths ) {
16121620 const sourceFilePath = path . normalize ( path . join ( projectRoot , filePath ) ) ;
16131621 filePathsArr . push ( sourceFilePath ) ;
16141622 }
16151623 } else {
1616- if ( this . $fs . exists ( rootPath ) ) {
1617- const stats = this . $fs . getFsStats ( rootPath ) ;
1618- if ( stats . isDirectory ( ) && ! this . $fs . isEmptyDir ( rootPath ) ) {
1619- this . $fs . readDirectory ( rootPath ) . forEach ( ( fileName ) => {
1624+ const folderPath = path . resolve ( projectRoot , rootPath ) ;
1625+ rootGroup . path = folderPath ;
1626+ if ( this . $fs . exists ( folderPath ) ) {
1627+ const stats = this . $fs . getFsStats ( folderPath ) ;
1628+ if ( stats . isDirectory ( ) && ! this . $fs . isEmptyDir ( folderPath ) ) {
1629+ this . $fs . readDirectory ( folderPath ) . forEach ( ( fileName ) => {
16201630 const filePath = path . join ( rootGroup . path , fileName ) ;
16211631 filePathsArr . push ( filePath ) ;
16221632 } ) ;
@@ -1684,6 +1694,7 @@ export class IOSProjectService
16841694 const group = await this . getRootGroup (
16851695 pluginData . name ,
16861696 pluginPlatformsFolderPath ,
1697+ projectData . projectDir ,
16871698 ) ;
16881699 project . removePbxGroup ( group . name , group . path ) ;
16891700 project . removeFromHeaderSearchPaths ( group . path ) ;
0 commit comments