@@ -349,8 +349,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
349349 return path . join ( this . platformData . projectRoot , "Podfile" ) ;
350350 }
351351
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" ) ;
354358 }
355359
356360 private replace ( name : string ) : string {
@@ -389,7 +393,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
389393 this . prepareFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
390394 this . prepareStaticLibs ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
391395 this . prepareCocoapods ( pluginPlatformsFolderPath ) . wait ( ) ;
392- this . prepareXcconfigFile ( pluginPlatformsFolderPath ) . wait ( ) ;
393396 } ) . future < void > ( ) ( ) ;
394397 }
395398
@@ -400,7 +403,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
400403 this . removeFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
401404 this . removeStaticLibs ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
402405 this . removeCocoapods ( pluginPlatformsFolderPath ) . wait ( ) ;
403- this . removeXcconfigFile ( pluginPlatformsFolderPath ) . wait ( ) ;
404406 } ) . future < void > ( ) ( ) ;
405407 }
406408
@@ -433,6 +435,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
433435
434436 this . executePodInstall ( ) . wait ( ) ;
435437 }
438+
439+ this . regeneratePluginsXcconfigFile ( ) . wait ( ) ;
436440 } ) . future < void > ( ) ( ) ;
437441 }
438442
@@ -535,16 +539,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
535539 } ) . future < void > ( ) ( ) ;
536540 }
537541
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-
548542 private removeFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData ) : IFuture < void > {
549543 return ( ( ) => {
550544 let project = this . createPbxProj ( ) ;
@@ -588,18 +582,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
588582 } else {
589583 this . $fs . writeFile ( this . projectPodFilePath , projectPodFileContent ) . wait ( ) ;
590584 }
591- }
592- } ) . future < void > ( ) ( ) ;
593- }
594585
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 ( ) ;
603586 }
604587 } ) . future < void > ( ) ( ) ;
605588 }
@@ -624,9 +607,38 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
624607 this . $fs . writeFile ( path . join ( headersFolderPath , "module.modulemap" ) , modulemap ) . wait ( ) ;
625608 }
626609
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 > ( ) ( ) ;
630642 }
631643}
632644
0 commit comments