Commit d054c8a6 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Init] Output a properly-formed `Podfile` when running `pod init` with a target…

[Init] Output a properly-formed `Podfile` when running `pod init` with a target that contains a `'` in its name.

Closes https://github.com/CocoaPods/CocoaPods/issues/3136.
parent a6b6ea04
...@@ -39,6 +39,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -39,6 +39,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#2983](https://github.com/CocoaPods/CocoaPods/issues/2983) [#2983](https://github.com/CocoaPods/CocoaPods/issues/2983)
* Output a properly-formed `Podfile` when running `pod init` with a target that
contains a `'` in its name.
[Samuel Giddins](https://github.com/segiddins)
[#3136](https://github.com/CocoaPods/CocoaPods/issues/3136)
## 0.36.0.beta.2 ## 0.36.0.beta.2
......
...@@ -72,7 +72,7 @@ module Pod ...@@ -72,7 +72,7 @@ module Pod
# @return [String] the text for the target module # @return [String] the text for the target module
# #
def target_module(target) def target_module(target)
target_module = "\ntarget '#{target.name}' do\n" target_module = "\ntarget '#{target.name.gsub(/'/, "\\\\\'")}' do\n"
if target.name =~ /tests?/i if target.name =~ /tests?/i
target_module << template_contents(config.default_test_podfile_path) target_module << template_contents(config.default_test_podfile_path)
......
...@@ -52,6 +52,7 @@ module Pod ...@@ -52,6 +52,7 @@ module Pod
project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj') project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj')
project.new_target(:application, 'AppA', :ios) project.new_target(:application, 'AppA', :ios)
project.new_target(:application, 'AppB', :ios) project.new_target(:application, 'AppB', :ios)
project.new_target(:application, "App'C", :ios)
project.save project.save
run_command('init') run_command('init')
...@@ -60,6 +61,7 @@ module Pod ...@@ -60,6 +61,7 @@ module Pod
config.podfile.target_definitions.length.should == project.targets.length + 1 config.podfile.target_definitions.length.should == project.targets.length + 1
config.podfile.target_definitions['AppA'].nil?.should == false config.podfile.target_definitions['AppA'].nil?.should == false
config.podfile.target_definitions['AppB'].nil?.should == false config.podfile.target_definitions['AppB'].nil?.should == false
config.podfile.target_definitions["App'C"].nil?.should == false
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