Commit 8a814f81 authored by Kyle Fuller's avatar Kyle Fuller

`pod init` shouild save xcodeproj if it was defined

parent 55117eb3
...@@ -16,6 +16,9 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -16,6 +16,9 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
* Improves the error message when searching with an invalid regular expression. * Improves the error message when searching with an invalid regular expression.
[Kyle Fuller](https://github.com/kylef) [Kyle Fuller](https://github.com/kylef)
* Improves `pod init` to save Xcode project file in Podfile when one was supplied.
[Kyle Fuller](https://github.com/kylef)
## 0.29.0 ## 0.29.0
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.28.0...0.29.0) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.28.0...0.29.0)
......
...@@ -31,12 +31,13 @@ module Pod ...@@ -31,12 +31,13 @@ module Pod
raise Informative, "Existing Podfile found in directory" unless config.podfile.nil? raise Informative, "Existing Podfile found in directory" unless config.podfile.nil?
if @project_path if @project_path
help! "Xcode project at #{@project_path} does not exist" unless File.exist? @project_path help! "Xcode project at #{@project_path} does not exist" unless File.exist? @project_path
project_path = @project_path
else else
raise Informative, "No xcode project found, please specify one" unless @project_paths.length > 0 raise Informative, "No xcode project found, please specify one" unless @project_paths.length > 0
raise Informative, "Multiple xcode projects found, please specify one" unless @project_paths.length == 1 raise Informative, "Multiple xcode projects found, please specify one" unless @project_paths.length == 1
@project_path = @project_paths.first project_path = @project_paths.first
end end
@xcode_project = Xcodeproj::Project.open(@project_path) @xcode_project = Xcodeproj::Project.open(project_path)
end end
def run def run
...@@ -51,7 +52,9 @@ module Pod ...@@ -51,7 +52,9 @@ module Pod
# @return [String] the text of the Podfile for the provided project # @return [String] the text of the Podfile for the provided project
# #
def podfile_template(project) def podfile_template(project)
podfile = <<-PLATFORM.strip_heredoc podfile = ''
podfile << "xcodeproj '#{@project_path}'\n\n" if @project_path
podfile << <<-PLATFORM.strip_heredoc
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
# platform :ios, "6.0" # platform :ios, "6.0"
PLATFORM PLATFORM
......
...@@ -122,5 +122,27 @@ module Pod ...@@ -122,5 +122,27 @@ module Pod
end end
end end
it "saves xcode project file in Podfile if one was supplied" do
Dir.chdir(temporary_directory) do
Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save
Xcodeproj::Project.new(temporary_directory + 'Project.xcodeproj').save
run_command('init', 'Project.xcodeproj')
target_definition = config.podfile.target_definitions.values.first
target_definition.user_project_path.should == 'Project.xcodeproj'
end
end
it "doesn't save xcode project file in Podfile if one wasn't supplied" do
Dir.chdir(temporary_directory) do
Xcodeproj::Project.new(temporary_directory + 'Project.xcodeproj').save
run_command('init')
target_definition = config.podfile.target_definitions.values.first
target_definition.user_project_path.should == nil
end
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment