Skip to content

Commit 10b2216

Browse files
committed
Merge pull request #848 from NativeScript/tpopov/generate-scheme
Create main target scheme before installing pods.
2 parents ae0ff1c + dd8708e commit 10b2216

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/services/ios-project-service.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
351351
// Check availability
352352
try {
353353
this.$childProcess.exec("gem which cocoapods").wait();
354+
this.$childProcess.exec("gem which xcodeproj").wait();
354355
} catch(e) {
355-
this.$errors.failWithoutHelp("CocoaPods are not installed. Run `sudo gem install cocoapods` and try again.");
356+
this.$errors.failWithoutHelp("CocoaPods or ruby gem 'xcodeproj' is not installed. Run `sudo gem install cocoapods` and try again.");
356357
}
357358

358359
let projectPodfileContent = this.$fs.readText(this.projectPodFilePath).wait();
@@ -363,7 +364,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
363364
if(firstPostInstallIndex !== -1 && firstPostInstallIndex !== projectPodfileContent.lastIndexOf(IOSProjectService.PODFILE_POST_INSTALL_SECTION_NAME)) {
364365
this.$logger.warn(`Podfile contains more than one post_install sections. You need to open ${this.projectPodFilePath} file and manually resolve this issue.`);
365366
}
366-
367+
368+
let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "xcuserdata");
369+
if(!this.$fs.exists(pbxprojFilePath).wait()) {
370+
this.$logger.info("Creating project scheme...");
371+
let createSchemeRubyScript = `ruby -e "require 'xcodeproj'; xcproj = Xcodeproj::Project.open('${this.$projectData.projectName}.xcodeproj'); xcproj.recreate_user_schemes; xcproj.save"`;
372+
this.$childProcess.exec(createSchemeRubyScript, { cwd: this.platformData.projectRoot }).wait();
373+
}
374+
367375
this.$logger.info("Installing pods...");
368376
this.$childProcess.exec("pod install", { cwd: this.platformData.projectRoot }).wait();
369377
}

0 commit comments

Comments
 (0)