Skip to content

Create main target scheme before installing pods. #848

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 2 commits into from
Sep 2, 2015
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Copy link
Contributor

Choose a reason for hiding this comment

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

We use only camelCase for variables. Consider naming it something like createSchemeRubyScript

Copy link
Contributor

Choose a reason for hiding this comment

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

I've tested on a clean machine with only Xcode 6.4, node and nativescript installed. In my case, the following error was shown:

require "xcodeproj"
LoadError: cannot load such file -- xcodeproj

Do we need to install some additional dependencies?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we go ruby way, you can consider using the one-liners syntax: ruby -e "our code here", which will save us some nasty escaping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ruby gem cocoapods depends on xcodeproj so it is automatically installed. Do you have the latest cocoapods v.0.38.2 ? Users can manually uninstall gem xcodeproj. However doing so will cause a few lines down the execution of pod install command to fail as well although there would be installed cocoapods (with missing xcodeproj). Here is a snippet of the error message:
`/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:into_specs': Could not find 'xcodeproj' (~> 0.26.3) among 35 total gem(s) (Gem::LoadError)

Perhaps there should be a check for installed xcodeproj gem as well. I've added it in the latest commit.

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();
}
Expand Down