Skip to content

Commit dbcb5b0

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

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

lib/services/ios-project-service.ts

+35-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
161161
let args: string[] = [];
162162
if(this.$options.forDevice) {
163163
args = basicArgs.concat([
164-
"-xcconfig", path.join(projectRoot, this.$projectData.projectName, "build.xcconfig"),
165164
"-sdk", "iphoneos",
166165
'ARCHS=armv7 arm64',
167166
'VALID_ARCHS=armv7 arm64',
@@ -333,6 +332,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
333332
return path.join(this.platformData.projectRoot, "Podfile");
334333
}
335334

335+
private get projectXcconfigFilePath(): string {
336+
return path.join(this.platformData.appDestinationDirectoryPath, "build.xcconfig");
337+
}
338+
336339
private replace(name: string): string {
337340
if(_.startsWith(name, '"')) {
338341
name = name.substr(1, name.length-2);
@@ -369,6 +372,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
369372
this.prepareFrameworks(pluginPlatformsFolderPath, pluginData).wait();
370373
this.prepareStaticLibs(pluginPlatformsFolderPath, pluginData).wait();
371374
this.prepareCocoapods(pluginPlatformsFolderPath).wait();
375+
this.prepareXcconfigFile(pluginPlatformsFolderPath).wait();
372376
}).future<void>()();
373377
}
374378

@@ -379,6 +383,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
379383
this.removeFrameworks(pluginPlatformsFolderPath, pluginData).wait();
380384
this.removeStaticLibs(pluginPlatformsFolderPath, pluginData).wait();
381385
this.removeCocoapods(pluginPlatformsFolderPath).wait();
386+
this.removeXcconfigFile(pluginPlatformsFolderPath).wait();
382387
}).future<void>()();
383388
}
384389

@@ -432,7 +437,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
432437

433438
let packageType = this.$childProcess.exec(`/usr/libexec/PlistBuddy -c "Print :CFBundlePackageType" "${infoPlistPath}"`).wait().trim();
434439
if (packageType !== "FMWK") {
435-
this.$errors.failWithoutHelp("The bundle at %s does not appear to be a dynamic framework.", libraryPath);
440+
this.$errors.failWithoutHelp("The bundle at %s does not appear to be a framework.", libraryPath);
436441
}
437442
}).future<void>()();
438443
}
@@ -509,6 +514,17 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
509514
}).future<void>()();
510515
}
511516

517+
private prepareXcconfigFile(pluginPlatformsFolderPath: string): IFuture<void> {
518+
return (() => {
519+
let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig");
520+
if(this.$fs.exists(pluginXcconfigFilePath).wait()) {
521+
let xcconfigContent = this.$fs.readText(pluginXcconfigFilePath).wait();
522+
let contentToWrite = this.buildXcconfigContent(pluginXcconfigFilePath, xcconfigContent);
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,19 @@ 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 xcconfigContent = this.$fs.readText(pluginXcconfigFilePath).wait();
580+
let projectXcconfigFileContent = this.$fs.readText(this.projectXcconfigFilePath).wait();
581+
let contentToRemove = this.buildXcconfigContent(pluginXcconfigFilePath, xcconfigContent);
582+
projectXcconfigFileContent = helpers.stringReplaceAll(projectXcconfigFileContent, contentToRemove, "");
583+
this.$fs.writeFile(this.projectXcconfigFilePath, projectXcconfigFileContent).wait();
584+
}
585+
}).future<void>()();
586+
}
587+
559588
private buildPodfileContent(pluginPodFilePath: string, pluginPodFileContent: string): string {
560589
return `# Begin Podfile - ${pluginPodFilePath} ${os.EOL} ${pluginPodFileContent} ${os.EOL} # End Podfile ${os.EOL}`;
561590
}
@@ -575,6 +604,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
575604
let modulemap = `module ${libraryName} { explicit module ${libraryName} { ${headers.join(" ")} } }`;
576605
this.$fs.writeFile(path.join(headersFolderPath, "module.modulemap"), modulemap).wait();
577606
}
607+
608+
private buildXcconfigContent(xcconfigFilePath: string, xcconfigFileContent: string): string {
609+
return `${os.EOL}// Begin xcconfig - ${xcconfigFilePath} ${os.EOL} ${xcconfigFileContent} ${os.EOL} // End xcconfig ${os.EOL}`;
610+
}
578611
}
579612

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

0 commit comments

Comments
 (0)