Permalink
Browse files

Raise an informative error if xcodeproj is not present in Podfile, fo…

…r now.
  • Loading branch information...
1 parent ff71c74 commit cd931998200c82fd189ccacb5c0caefe75b0ee7c @subdigital subdigital committed with alloy Mar 9, 2012
Showing with 55 additions and 10 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 TODO
  3. +23 −9 lib/cocoapods/command/install.rb
  4. +1 −1 lib/cocoapods/installer.rb
  5. +28 −0 spec/unit/install_command_spec.rb
View
@@ -3,6 +3,7 @@
*.rbo
*.gem
.DS_Store
+.rbenv-version
xcuserdata
project.xcworkspace
DerivedData
View
2 TODO
@@ -1,3 +1,5 @@
+* No need to pass the project path and podfile separately to UserProjectIntegrator.
+* Move Platform#xcodeproj to TargetDefinition#link_with.
* Add multiple-platforms section to changelog.
* Validate platforms for each target definition.
* Validate that there are dependencies in a Podfile.
@@ -4,16 +4,22 @@ class Install < Command
def self.banner
%{Installing dependencies of a project:
- $ pod install [PROJECT]
+ $ pod install
Downloads all dependencies defined in `Podfile' and creates an Xcode
Pods library project in `./Pods'.
- In case `PROJECT' is given, it configures it to use the specified Pods
- and generates a workspace with the Pods project and `PROJECT'. (It is
- important that once you have run this you open the workspace instead of
- `PROJECT'.) You usually specify `PROJECT' only the first time that you
- run `pod install'.
+ The Xcode project file should be specified in your `Podfile` like this:
+
+ xcodeproj "path/to/project.xcodeproj"
+
+ If no xcodeproj is specified, then a search for an Xcode project will
+ be made. If more than one Xcode project is found, the command will
+ raise an error.
+
+ This will configure the project to reference the Pods static library,
+ add a build configuration file, and add a post build script to copy
+ Pod resources.
}
end
@@ -30,21 +36,29 @@ def initialize(argv)
config.doc = !argv.option('--no-doc')
config.force_doc = argv.option('--force-doc')
@update_repo = !argv.option('--no-update')
- @projpath = argv.shift_argument
super unless argv.empty?
end
def run
unless podfile = config.podfile
raise Informative, "No `Podfile' found in the current working directory."
end
- if @projpath && !File.exist?(@projpath)
- raise Informative, "The specified project `#{@projpath}' does not exist."
+
+ if podfile.xcodeproj.nil?
+ raise Informative, "Please specify a valid xcodeproj path in your Podfile.\n\n" +
+ "Usage:\n\t" +
+ "xcodeproj 'path/to/project.xcodeproj'"
+ end
+
+ unless File.exist?(podfile.xcodeproj)
+ raise Informative, "The specified project `#{podfile.xcodeproj}' does not exist."
end
+
if @update_repo
puts "\nUpdating Spec Repositories\n".yellow if config.verbose?
Repo.new(ARGV.new(["update"])).run
end
+
Installer.new(podfile, @projpath).install!
end
end
@@ -91,7 +91,7 @@ def install!
puts "* Writing Xcode project file to `#{@sandbox.project_path}'\n\n" if config.verbose?
project.save_as(@sandbox.project_path)
- UserProjectIntegrator.new(@user_project_path, @podfile).integrate! if @user_project_path
+ UserProjectIntegrator.new(@podfile.xcodeproj, @podfile).integrate!
end
def run_post_install_hooks
@@ -0,0 +1,28 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe "Pod::Command::Install" do
+ it "should include instructions on how to reference the xcode project" do
+ Pod::Command::Install.banner.should.match /xcodeproj path\/to\/project.xcodeproj/
+ end
+
+ before do
+ @config_before = config
+ Pod::Config.instance = nil
+ config.silent = true
+ end
+
+ after do
+ Pod::Config.instance = @config_before
+ end
+
+ describe "When the Podfile does not specify the xcodeproject" do
+ before do
+ config.stubs(:rootspec).returns(Pod::Podfile.new { platform :ios; dependency 'AFNetworking'})
+ end
+ it "raises an informative error if the xcodproj is not specified in the podfile" do
+ installer = Pod::Command::Install.new(Pod::Command::ARGV.new)
+ should.raise(Pod::Informative) { installer.run }
+ end
+ end
+end
+

0 comments on commit cd93199

Please sign in to comment.