Skip to content

Commit ab8a1b4

Browse files
committed
Merge pull request #1680 from NativeScript/kerezov/cocoa-pods-1.0.0
Add a target to the Podfile
2 parents 24bec80 + d8339a3 commit ab8a1b4

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

lib/services/ios-project-service.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
690690
let pluginPodFilePath = path.join(pluginPlatformsFolderPath, "Podfile");
691691

692692
if(this.$fs.exists(pluginPodFilePath).wait()) {
693-
if(!this.$fs.exists(this.projectPodFilePath).wait()) {
694-
this.$fs.writeFile(this.projectPodFilePath, "use_frameworks!\n").wait();
695-
}
696-
697693
let pluginPodFileContent = this.$fs.readText(pluginPodFilePath).wait();
698-
let contentToWrite = this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
699-
this.$fs.appendFile(this.projectPodFilePath, contentToWrite).wait();
694+
let contentToWrite = `use_frameworks!${os.EOL}${os.EOL}target "${this.$projectData.projectName}" do${os.EOL}${this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent)}${os.EOL}end`;
695+
this.$fs.writeFile(this.projectPodFilePath, contentToWrite).wait();
700696

701697
let project = this.createPbxProj();
702698
project.updateBuildProperty("IPHONEOS_DEPLOYMENT_TARGET", "8.0");
@@ -748,7 +744,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
748744
let projectPodFileContent = this.$fs.readText(this.projectPodFilePath).wait();
749745
let contentToRemove= this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
750746
projectPodFileContent = helpers.stringReplaceAll(projectPodFileContent, contentToRemove, "");
751-
if(projectPodFileContent.trim() === "use_frameworks!") {
747+
if(projectPodFileContent.trim() === `use_frameworks!${os.EOL}${os.EOL}target "${this.$projectData.projectName}" do${os.EOL}${os.EOL}end`) {
752748
this.$fs.deleteFile(this.projectPodFilePath).wait();
753749
} else {
754750
this.$fs.writeFile(this.projectPodFilePath, projectPodFileContent).wait();
@@ -812,10 +808,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
812808
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.pluginsReleaseXcconfigFilePath).wait();
813809
}
814810

815-
let podFolder = path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/");
811+
let podFilesRootDirName = path.join("Pods", "Target Support Files", `Pods-${this.$projectData.projectName}`);
812+
let podFolder = path.join(this.platformData.projectRoot, podFilesRootDirName);
816813
if (this.$fs.exists(podFolder).wait()) {
817-
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/Pods.debug.xcconfig"), this.pluginsDebugXcconfigFilePath).wait();
818-
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, "Pods/Target Support Files/Pods/Pods.release.xcconfig"), this.pluginsReleaseXcconfigFilePath).wait();
814+
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.debug.xcconfig`), this.pluginsDebugXcconfigFilePath).wait();
815+
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.release.xcconfig`), this.pluginsReleaseXcconfigFilePath).wait();
819816
}
820817
}).future<void>()();
821818
}

test/ios-project-service.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ describe("Cocoapods support", () => {
154154
assert.isTrue(fs.exists(projectPodfilePath).wait());
155155

156156
let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
157-
let expectedProjectPodfileContent = ["use_frameworks!",
157+
let expectedProjectPodfileContent = ["use_frameworks!\n",
158+
`target "${projectName}" do`,
158159
`# Begin Podfile - ${pluginPodfilePath} `,
159160
` ${pluginPodfileContent} `,
160-
" # End Podfile \n"]
161+
" # End Podfile \n",
162+
"end"]
161163
.join("\n");
162164
assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
163165
});
@@ -221,10 +223,12 @@ describe("Cocoapods support", () => {
221223
assert.isTrue(fs.exists(projectPodfilePath).wait());
222224

223225
let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
224-
let expectedProjectPodfileContent = ["use_frameworks!",
226+
let expectedProjectPodfileContent = ["use_frameworks!\n",
227+
`target "${projectName}" do`,
225228
`# Begin Podfile - ${pluginPodfilePath} `,
226229
` ${pluginPodfileContent} `,
227-
" # End Podfile \n"]
230+
" # End Podfile \n",
231+
"end"]
228232
.join("\n");
229233
assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
230234

0 commit comments

Comments
 (0)