Skip to content

Commit a2ade30

Browse files
committed
Support xcconfig file from plugin - close #883
1 parent 084ff4d commit a2ade30

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

lib/services/ios-project-service.ts

+35-1
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

@@ -432,7 +438,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
432438

433439
let packageType = this.$childProcess.exec(`/usr/libexec/PlistBuddy -c "Print :CFBundlePackageType" "${infoPlistPath}"`).wait().trim();
434440
if (packageType !== "FMWK") {
435-
this.$errors.failWithoutHelp("The bundle at %s does not appear to be a dynamic framework.", libraryPath);
441+
this.$errors.failWithoutHelp("The bundle at %s does not appear to be a framework.", libraryPath);
436442
}
437443
}).future<void>()();
438444
}
@@ -509,6 +515,17 @@ 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 xcconfigContent = this.$fs.readText(pluginXcconfigFilePath).wait();
523+
let contentToWrite = this.buildXcconfigContent(pluginXcconfigFilePath, xcconfigContent);
524+
this.$fs.appendFile(this.projectXcconfigFilePath, contentToWrite).wait();
525+
}
526+
}).future<void>()();
527+
}
528+
512529
private removeFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture<void> {
513530
return (() => {
514531
let project = this.createPbxProj();
@@ -556,6 +573,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
556573
}).future<void>()();
557574
}
558575

576+
private removeXcconfigFile(pluginPlatformsFolderPath: string): IFuture<void> {
577+
return (() => {
578+
let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig");
579+
if(this.$fs.exists(pluginXcconfigFilePath).wait()) {
580+
let xcconfigContent = this.$fs.readText(pluginXcconfigFilePath).wait();
581+
let projectXcconfigFileContent = this.$fs.readText(this.projectXcconfigFilePath).wait();
582+
let contentToRemove = this.buildXcconfigContent(pluginXcconfigFilePath, xcconfigContent);
583+
projectXcconfigFileContent = helpers.stringReplaceAll(projectXcconfigFileContent, contentToRemove, "");
584+
this.$fs.writeFile(this.projectXcconfigFilePath, projectXcconfigFileContent).wait();
585+
}
586+
}).future<void>()();
587+
}
588+
559589
private buildPodfileContent(pluginPodFilePath: string, pluginPodFileContent: string): string {
560590
return `# Begin Podfile - ${pluginPodFilePath} ${os.EOL} ${pluginPodFileContent} ${os.EOL} # End Podfile ${os.EOL}`;
561591
}
@@ -575,6 +605,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
575605
let modulemap = `module ${libraryName} { explicit module ${libraryName} { ${headers.join(" ")} } }`;
576606
this.$fs.writeFile(path.join(headersFolderPath, "module.modulemap"), modulemap).wait();
577607
}
608+
609+
private buildXcconfigContent(xcconfigFilePath: string, xcconfigFileContent: string): string {
610+
return `${os.EOL}// Begin xcconfig - ${xcconfigFilePath} ${os.EOL} ${xcconfigFileContent} ${os.EOL} // End xcconfig ${os.EOL}`;
611+
}
578612
}
579613

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

0 commit comments

Comments
 (0)