@@ -349,8 +349,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
349
349
return path . join ( this . platformData . projectRoot , "Podfile" ) ;
350
350
}
351
351
352
- private get projectXcconfigFilePath ( ) : string {
353
- return path . join ( this . platformData . appDestinationDirectoryPath , "build.xcconfig" ) ;
352
+ private get pluginsDebugXcconfigFilePath ( ) : string {
353
+ return path . join ( this . platformData . projectRoot , "plugins-debug.xcconfig" ) ;
354
+ }
355
+
356
+ private get pluginsReleaseXcconfigFilePath ( ) : string {
357
+ return path . join ( this . platformData . projectRoot , "plugins-release.xcconfig" ) ;
354
358
}
355
359
356
360
private replace ( name : string ) : string {
@@ -389,7 +393,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
389
393
this . prepareFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
390
394
this . prepareStaticLibs ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
391
395
this . prepareCocoapods ( pluginPlatformsFolderPath ) . wait ( ) ;
392
- this . prepareXcconfigFile ( pluginPlatformsFolderPath ) . wait ( ) ;
393
396
} ) . future < void > ( ) ( ) ;
394
397
}
395
398
@@ -400,7 +403,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
400
403
this . removeFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
401
404
this . removeStaticLibs ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
402
405
this . removeCocoapods ( pluginPlatformsFolderPath ) . wait ( ) ;
403
- this . removeXcconfigFile ( pluginPlatformsFolderPath ) . wait ( ) ;
404
406
} ) . future < void > ( ) ( ) ;
405
407
}
406
408
@@ -433,6 +435,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
433
435
434
436
this . executePodInstall ( ) . wait ( ) ;
435
437
}
438
+
439
+ this . regeneratePluginsXcconfigFile ( ) . wait ( ) ;
436
440
} ) . future < void > ( ) ( ) ;
437
441
}
438
442
@@ -535,16 +539,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
535
539
} ) . future < void > ( ) ( ) ;
536
540
}
537
541
538
- private prepareXcconfigFile ( pluginPlatformsFolderPath : string ) : IFuture < void > {
539
- return ( ( ) => {
540
- let pluginXcconfigFilePath = path . join ( pluginPlatformsFolderPath , "build.xcconfig" ) ;
541
- if ( this . $fs . exists ( pluginXcconfigFilePath ) . wait ( ) ) {
542
- let contentToWrite = this . buildXcconfigContent ( pluginXcconfigFilePath ) ;
543
- this . $fs . appendFile ( this . projectXcconfigFilePath , contentToWrite ) . wait ( ) ;
544
- }
545
- } ) . future < void > ( ) ( ) ;
546
- }
547
-
548
542
private removeFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData ) : IFuture < void > {
549
543
return ( ( ) => {
550
544
let project = this . createPbxProj ( ) ;
@@ -588,18 +582,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
588
582
} else {
589
583
this . $fs . writeFile ( this . projectPodFilePath , projectPodFileContent ) . wait ( ) ;
590
584
}
591
- }
592
- } ) . future < void > ( ) ( ) ;
593
- }
594
585
595
- private removeXcconfigFile ( pluginPlatformsFolderPath : string ) : IFuture < void > {
596
- return ( ( ) => {
597
- let pluginXcconfigFilePath = path . join ( pluginPlatformsFolderPath , "build.xcconfig" ) ;
598
- if ( this . $fs . exists ( pluginXcconfigFilePath ) . wait ( ) ) {
599
- let projectXcconfigFileContent = this . $fs . readText ( this . projectXcconfigFilePath ) . wait ( ) ;
600
- let contentToRemove = this . buildXcconfigContent ( pluginXcconfigFilePath ) ;
601
- projectXcconfigFileContent = helpers . stringReplaceAll ( projectXcconfigFileContent , contentToRemove , "" ) ;
602
- this . $fs . writeFile ( this . projectXcconfigFilePath , projectXcconfigFileContent ) . wait ( ) ;
603
586
}
604
587
} ) . future < void > ( ) ( ) ;
605
588
}
@@ -624,9 +607,38 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
624
607
this . $fs . writeFile ( path . join ( headersFolderPath , "module.modulemap" ) , modulemap ) . wait ( ) ;
625
608
}
626
609
627
- private buildXcconfigContent ( xcconfigFilePath : string ) : string {
628
- let relativePluginXcconfigFilePath = path . relative ( path . dirname ( this . projectXcconfigFilePath ) , xcconfigFilePath ) ;
629
- return `${ os . EOL } #include "${ relativePluginXcconfigFilePath } "${ os . EOL } ` ;
610
+ private mergeXcconfigFiles ( pluginFile : string , projectFile : string ) : IFuture < void > {
611
+ return ( ( ) => {
612
+ if ( ! this . $fs . exists ( projectFile ) . wait ( ) ) {
613
+ this . $fs . writeFile ( projectFile , "" ) . wait ( ) ;
614
+ }
615
+
616
+ let mergeScript = `require 'xcodeproj'; Xcodeproj::Config.new('${ projectFile } ').merge(Xcodeproj::Config.new('${ pluginFile } ')).save_as(Pathname.new('${ projectFile } '))` ;
617
+ this . $childProcess . exec ( `ruby -e "${ mergeScript } "` ) . wait ( ) ;
618
+ } ) . future < void > ( ) ( ) ;
619
+ }
620
+
621
+ private regeneratePluginsXcconfigFile ( ) : IFuture < void > {
622
+ return ( ( ) => {
623
+ this . $fs . deleteFile ( this . pluginsDebugXcconfigFilePath ) . wait ( ) ;
624
+ this . $fs . deleteFile ( this . pluginsReleaseXcconfigFilePath ) . wait ( ) ;
625
+
626
+ let allPlugins : IPluginData [ ] = ( < IPluginsService > this . $injector . resolve ( "pluginsService" ) ) . getAllInstalledPlugins ( ) . wait ( ) ;
627
+ for ( let plugin of allPlugins ) {
628
+ let pluginPlatformsFolderPath = plugin . pluginPlatformsFolderPath ( IOSProjectService . IOS_PLATFORM_NAME ) ;
629
+ let pluginXcconfigFilePath = path . join ( pluginPlatformsFolderPath , "build.xcconfig" ) ;
630
+ if ( this . $fs . exists ( pluginXcconfigFilePath ) . wait ( ) ) {
631
+ this . mergeXcconfigFiles ( pluginXcconfigFilePath , this . pluginsDebugXcconfigFilePath ) . wait ( ) ;
632
+ this . mergeXcconfigFiles ( pluginXcconfigFilePath , this . pluginsReleaseXcconfigFilePath ) . wait ( ) ;
633
+ }
634
+ }
635
+
636
+ let podFolder = path . join ( this . platformData . projectRoot , "Pods/Target Support Files/Pods/" ) ;
637
+ if ( this . $fs . exists ( podFolder ) . wait ( ) ) {
638
+ this . mergeXcconfigFiles ( path . join ( this . platformData . projectRoot , "Pods/Target Support Files/Pods/Pods.debug.xcconfig" ) , this . pluginsDebugXcconfigFilePath ) . wait ( ) ;
639
+ this . mergeXcconfigFiles ( path . join ( this . platformData . projectRoot , "Pods/Target Support Files/Pods/Pods.release.xcconfig" ) , this . pluginsReleaseXcconfigFilePath ) . wait ( ) ;
640
+ }
641
+ } ) . future < void > ( ) ( ) ;
630
642
}
631
643
}
632
644
0 commit comments