Skip to content

Add a target to the Podfile #1680

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
Apr 15, 2016
Merged
Show file tree
Hide file tree
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
17 changes: 7 additions & 10 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
let pluginPodFilePath = path.join(pluginPlatformsFolderPath, "Podfile");

if(this.$fs.exists(pluginPodFilePath).wait()) {
if(!this.$fs.exists(this.projectPodFilePath).wait()) {
this.$fs.writeFile(this.projectPodFilePath, "use_frameworks!\n").wait();
}

let pluginPodFileContent = this.$fs.readText(pluginPodFilePath).wait();
let contentToWrite = this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
this.$fs.appendFile(this.projectPodFilePath, contentToWrite).wait();
let contentToWrite = `use_frameworks!${os.EOL}${os.EOL}target "${this.$projectData.projectName}" do${os.EOL}${this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent)}${os.EOL}end`;
this.$fs.writeFile(this.projectPodFilePath, contentToWrite).wait();

let project = this.createPbxProj();
project.updateBuildProperty("IPHONEOS_DEPLOYMENT_TARGET", "8.0");
Expand Down Expand Up @@ -747,7 +743,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
let projectPodFileContent = this.$fs.readText(this.projectPodFilePath).wait();
let contentToRemove= this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
projectPodFileContent = helpers.stringReplaceAll(projectPodFileContent, contentToRemove, "");
if(projectPodFileContent.trim() === "use_frameworks!") {
if(projectPodFileContent.trim() === `use_frameworks!${os.EOL}${os.EOL}target "${this.$projectData.projectName}" do${os.EOL}${os.EOL}end`) {
this.$fs.deleteFile(this.projectPodFilePath).wait();
} else {
this.$fs.writeFile(this.projectPodFilePath, projectPodFileContent).wait();
Expand Down Expand Up @@ -811,10 +807,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.pluginsReleaseXcconfigFilePath).wait();
}

let podFolder = path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/");
let podFilesRootDirName = path.join("Pods", "Target Support Files", `Pods-${this.$projectData.projectName}`);
let podFolder = path.join(this.platformData.projectRoot, podFilesRootDirName);
if (this.$fs.exists(podFolder).wait()) {
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/Pods.debug.xcconfig"), this.pluginsDebugXcconfigFilePath).wait();
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/Pods.release.xcconfig"), this.pluginsReleaseXcconfigFilePath).wait();
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.debug.xcconfig`), this.pluginsDebugXcconfigFilePath).wait();
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.release.xcconfig`), this.pluginsReleaseXcconfigFilePath).wait();
}
}).future<void>()();
}
Expand Down
12 changes: 8 additions & 4 deletions test/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ describe("Cocoapods support", () => {
assert.isTrue(fs.exists(projectPodfilePath).wait());

let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
let expectedProjectPodfileContent = ["use_frameworks!",
let expectedProjectPodfileContent = ["use_frameworks!\n",
`target "${projectName}" do`,
`# Begin Podfile - ${pluginPodfilePath} `,
` ${pluginPodfileContent} `,
" # End Podfile \n"]
" # End Podfile \n",
"end"]
.join("\n");
assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
});
Expand Down Expand Up @@ -221,10 +223,12 @@ describe("Cocoapods support", () => {
assert.isTrue(fs.exists(projectPodfilePath).wait());

let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
let expectedProjectPodfileContent = ["use_frameworks!",
let expectedProjectPodfileContent = ["use_frameworks!\n",
`target "${projectName}" do`,
`# Begin Podfile - ${pluginPodfilePath} `,
` ${pluginPodfileContent} `,
" # End Podfile \n"]
" # End Podfile \n",
"end"]
.join("\n");
assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);

Expand Down