From ae3d5c0620ee96ee0330abe0986dc95051da73a5 Mon Sep 17 00:00:00 2001 From: Toma Popov Date: Wed, 2 Sep 2015 11:25:22 +0300 Subject: [PATCH 1/2] Create main target scheme before installing pods. --- lib/services/ios-project-service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 4bd57e2cd1..1f99ea5f69 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -347,7 +347,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ if(firstPostInstallIndex !== -1 && firstPostInstallIndex !== projectPodfileContent.lastIndexOf(IOSProjectService.PODFILE_POST_INSTALL_SECTION_NAME)) { this.$logger.warn(`Podfile contains more than one post_install sections. You need to open ${this.projectPodFilePath} file and manually resolve this issue.`); } - + + let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "xcuserdata"); + if(!this.$fs.exists(pbxprojFilePath).wait()) { + this.$logger.info("Creating project scheme..."); + let createScheme_rb = `echo \"require 'xcodeproj'; xcproj = Xcodeproj::Project.open('${this.$projectData.projectName}.xcodeproj'); xcproj.recreate_user_schemes; xcproj.save\" | ruby`; + this.$childProcess.exec(createScheme_rb, { cwd: this.platformData.projectRoot }).wait(); + } + this.$logger.info("Installing pods..."); this.$childProcess.exec("pod install", { cwd: this.platformData.projectRoot }).wait(); } From dd8708e6264d6807347d0c7252d39468bdb40398 Mon Sep 17 00:00:00 2001 From: Toma Popov Date: Wed, 2 Sep 2015 14:06:23 +0300 Subject: [PATCH 2/2] Fix coding style. Use ruby one-liners syntax. Add check for xcodeproj gem. --- lib/services/ios-project-service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 1f99ea5f69..2918f9d64e 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -335,8 +335,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ // Check availability try { this.$childProcess.exec("gem which cocoapods").wait(); + this.$childProcess.exec("gem which xcodeproj").wait(); } catch(e) { - this.$errors.failWithoutHelp("CocoaPods are not installed. Run `sudo gem install cocoapods` and try again."); + this.$errors.failWithoutHelp("CocoaPods or ruby gem 'xcodeproj' is not installed. Run `sudo gem install cocoapods` and try again."); } let projectPodfileContent = this.$fs.readText(this.projectPodFilePath).wait(); @@ -351,8 +352,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "xcuserdata"); if(!this.$fs.exists(pbxprojFilePath).wait()) { this.$logger.info("Creating project scheme..."); - let createScheme_rb = `echo \"require 'xcodeproj'; xcproj = Xcodeproj::Project.open('${this.$projectData.projectName}.xcodeproj'); xcproj.recreate_user_schemes; xcproj.save\" | ruby`; - this.$childProcess.exec(createScheme_rb, { cwd: this.platformData.projectRoot }).wait(); + let createSchemeRubyScript = `ruby -e "require 'xcodeproj'; xcproj = Xcodeproj::Project.open('${this.$projectData.projectName}.xcodeproj'); xcproj.recreate_user_schemes; xcproj.save"`; + this.$childProcess.exec(createSchemeRubyScript, { cwd: this.platformData.projectRoot }).wait(); } this.$logger.info("Installing pods...");