Skip to content

Support xcconfig file from plugin - close #883 #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<void>()();
}

Expand All @@ -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<void>()();
}

Expand Down Expand Up @@ -509,6 +515,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}).future<void>()();
}

private prepareXcconfigFile(pluginPlatformsFolderPath: string): IFuture<void> {
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we import the file instead append?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We append an #include "pluginFileXcconfig", is that what you mean?

}
}).future<void>()();
}

private removeFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture<void> {
return (() => {
let project = this.createPbxProj();
Expand Down Expand Up @@ -556,6 +572,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}).future<void>()();
}

private removeXcconfigFile(pluginPlatformsFolderPath: string): IFuture<void> {
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<void>()();
}

private buildPodfileContent(pluginPodFilePath: string, pluginPodFileContent: string): string {
return `# Begin Podfile - ${pluginPodFilePath} ${os.EOL} ${pluginPodFileContent} ${os.EOL} # End Podfile ${os.EOL}`;
}
Expand All @@ -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);