Skip to content

Commit 5c88305

Browse files
committed
Merge pull request #910 from NativeScript/jasssonpet/xcconfig-files
Support xcconfig file from plugin - close #883
2 parents 084ff4d + 86fd968 commit 5c88305

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

lib/services/ios-project-service.ts

+33
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
333333
return path.join(this.platformData.projectRoot, "Podfile");
334334
}
335335

336+
private get projectXcconfigFilePath(): string {
337+
return path.join(this.platformData.appDestinationDirectoryPath, "build.xcconfig");
338+
}
339+
336340
private replace(name: string): string {
337341
if(_.startsWith(name, '"')) {
338342
name = name.substr(1, name.length-2);
@@ -369,6 +373,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
369373
this.prepareFrameworks(pluginPlatformsFolderPath, pluginData).wait();
370374
this.prepareStaticLibs(pluginPlatformsFolderPath, pluginData).wait();
371375
this.prepareCocoapods(pluginPlatformsFolderPath).wait();
376+
this.prepareXcconfigFile(pluginPlatformsFolderPath).wait();
372377
}).future<void>()();
373378
}
374379

@@ -379,6 +384,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
379384
this.removeFrameworks(pluginPlatformsFolderPath, pluginData).wait();
380385
this.removeStaticLibs(pluginPlatformsFolderPath, pluginData).wait();
381386
this.removeCocoapods(pluginPlatformsFolderPath).wait();
387+
this.removeXcconfigFile(pluginPlatformsFolderPath).wait();
382388
}).future<void>()();
383389
}
384390

@@ -509,6 +515,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
509515
}).future<void>()();
510516
}
511517

518+
private prepareXcconfigFile(pluginPlatformsFolderPath: string): IFuture<void> {
519+
return (() => {
520+
let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig");
521+
if(this.$fs.exists(pluginXcconfigFilePath).wait()) {
522+
let contentToWrite = this.buildXcconfigContent(pluginXcconfigFilePath);
523+
this.$fs.appendFile(this.projectXcconfigFilePath, contentToWrite).wait();
524+
}
525+
}).future<void>()();
526+
}
527+
512528
private removeFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture<void> {
513529
return (() => {
514530
let project = this.createPbxProj();
@@ -556,6 +572,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
556572
}).future<void>()();
557573
}
558574

575+
private removeXcconfigFile(pluginPlatformsFolderPath: string): IFuture<void> {
576+
return (() => {
577+
let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig");
578+
if(this.$fs.exists(pluginXcconfigFilePath).wait()) {
579+
let projectXcconfigFileContent = this.$fs.readText(this.projectXcconfigFilePath).wait();
580+
let contentToRemove = this.buildXcconfigContent(pluginXcconfigFilePath);
581+
projectXcconfigFileContent = helpers.stringReplaceAll(projectXcconfigFileContent, contentToRemove, "");
582+
this.$fs.writeFile(this.projectXcconfigFilePath, projectXcconfigFileContent).wait();
583+
}
584+
}).future<void>()();
585+
}
586+
559587
private buildPodfileContent(pluginPodFilePath: string, pluginPodFileContent: string): string {
560588
return `# Begin Podfile - ${pluginPodFilePath} ${os.EOL} ${pluginPodFileContent} ${os.EOL} # End Podfile ${os.EOL}`;
561589
}
@@ -575,6 +603,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
575603
let modulemap = `module ${libraryName} { explicit module ${libraryName} { ${headers.join(" ")} } }`;
576604
this.$fs.writeFile(path.join(headersFolderPath, "module.modulemap"), modulemap).wait();
577605
}
606+
607+
private buildXcconfigContent(xcconfigFilePath: string): string {
608+
let relativePluginXcconfigFilePath = path.relative(path.dirname(this.projectXcconfigFilePath), xcconfigFilePath);
609+
return `${os.EOL}#include "${relativePluginXcconfigFilePath}"${os.EOL}`;
610+
}
578611
}
579612

580613
$injector.register("iOSProjectService", IOSProjectService);

0 commit comments

Comments
 (0)