diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index c893dbd0d9..3e05bf6a7c 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -333,6 +333,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ return path.join(this.platformData.projectRoot, "Podfile"); } + private get projectXcconfigFilePath(): string { + return path.join(this.platformData.appDestinationDirectoryPath, "build.xcconfig"); + } + private replace(name: string): string { if(_.startsWith(name, '"')) { name = name.substr(1, name.length-2); @@ -369,6 +373,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ this.prepareFrameworks(pluginPlatformsFolderPath, pluginData).wait(); this.prepareStaticLibs(pluginPlatformsFolderPath, pluginData).wait(); this.prepareCocoapods(pluginPlatformsFolderPath).wait(); + this.prepareXcconfigFile(pluginPlatformsFolderPath).wait(); }).future()(); } @@ -379,6 +384,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ this.removeFrameworks(pluginPlatformsFolderPath, pluginData).wait(); this.removeStaticLibs(pluginPlatformsFolderPath, pluginData).wait(); this.removeCocoapods(pluginPlatformsFolderPath).wait(); + this.removeXcconfigFile(pluginPlatformsFolderPath).wait(); }).future()(); } @@ -509,6 +515,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ }).future()(); } + private prepareXcconfigFile(pluginPlatformsFolderPath: string): IFuture { + return (() => { + let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig"); + if(this.$fs.exists(pluginXcconfigFilePath).wait()) { + let contentToWrite = this.buildXcconfigContent(pluginXcconfigFilePath); + this.$fs.appendFile(this.projectXcconfigFilePath, contentToWrite).wait(); + } + }).future()(); + } + private removeFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture { return (() => { let project = this.createPbxProj(); @@ -556,6 +572,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ }).future()(); } + private removeXcconfigFile(pluginPlatformsFolderPath: string): IFuture { + return (() => { + let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig"); + if(this.$fs.exists(pluginXcconfigFilePath).wait()) { + let projectXcconfigFileContent = this.$fs.readText(this.projectXcconfigFilePath).wait(); + let contentToRemove = this.buildXcconfigContent(pluginXcconfigFilePath); + projectXcconfigFileContent = helpers.stringReplaceAll(projectXcconfigFileContent, contentToRemove, ""); + this.$fs.writeFile(this.projectXcconfigFilePath, projectXcconfigFileContent).wait(); + } + }).future()(); + } + private buildPodfileContent(pluginPodFilePath: string, pluginPodFileContent: string): string { return `# Begin Podfile - ${pluginPodFilePath} ${os.EOL} ${pluginPodFileContent} ${os.EOL} # End Podfile ${os.EOL}`; } @@ -575,6 +603,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ let modulemap = `module ${libraryName} { explicit module ${libraryName} { ${headers.join(" ")} } }`; this.$fs.writeFile(path.join(headersFolderPath, "module.modulemap"), modulemap).wait(); } + + private buildXcconfigContent(xcconfigFilePath: string): string { + let relativePluginXcconfigFilePath = path.relative(path.dirname(this.projectXcconfigFilePath), xcconfigFilePath); + return `${os.EOL}#include "${relativePluginXcconfigFilePath}"${os.EOL}`; + } } $injector.register("iOSProjectService", IOSProjectService);