Commit 6159183f authored by Fabio Pelosin's avatar Fabio Pelosin

[Analyzer] Adapt for TargetDefinition#link_with_first_target

parent e515bb4d
...@@ -383,7 +383,7 @@ module Pod ...@@ -383,7 +383,7 @@ module Pod
if link_with = target_definition.link_with if link_with = target_definition.link_with
targets = native_targets(user_project).select { |t| link_with.include?(t.name) } targets = native_targets(user_project).select { |t| link_with.include?(t.name) }
raise Informative, "Unable to find the targets named `#{link_with.to_sentence}` to link with target definition `#{target_definition.name}`" if targets.empty? raise Informative, "Unable to find the targets named `#{link_with.to_sentence}` to link with target definition `#{target_definition.name}`" if targets.empty?
elsif target_definition.name == :default elsif target_definition.link_with_first_target?
targets = [ native_targets(user_project).first ].compact targets = [ native_targets(user_project).first ].compact
raise Informative, "Unable to find a target" if targets.empty? raise Informative, "Unable to find a target" if targets.empty?
else else
......
require File.expand_path('../spec_helper', __FILE__) require File.expand_path('../spec_helper', __FILE__)
require 'yaml' require 'yaml'
#-----------------------------------------------------------------------------#
# TODO These checks need to be migrated to spec/integration_2.rb
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# @!group Helpers # @!group Helpers
...@@ -212,7 +214,7 @@ module Pod ...@@ -212,7 +214,7 @@ module Pod
saved_project = Xcodeproj.read_plist(project_file) saved_project = Xcodeproj.read_plist(project_file)
saved_project.should == installer.pods_project.to_hash saved_project.should == installer.pods_project.to_hash
should_xcodebuild(podfile.target_definitions[:default]) should_xcodebuild(podfile.target_definitions['Pods'])
end end
#--------------------------------------# #--------------------------------------#
...@@ -293,7 +295,7 @@ module Pod ...@@ -293,7 +295,7 @@ module Pod
(config.sandbox_root + file).should.exist (config.sandbox_root + file).should.exist
end end
should_xcodebuild(podfile.target_definitions[:default]) should_xcodebuild(podfile.target_definitions['Pods'])
should_xcodebuild(podfile.target_definitions[:debug]) should_xcodebuild(podfile.target_definitions[:debug])
should_xcodebuild(podfile.target_definitions[:test]) should_xcodebuild(podfile.target_definitions[:test])
end end
......
...@@ -269,7 +269,8 @@ module Pod ...@@ -269,7 +269,8 @@ module Pod
end end
it "returns the first target of the project if the target definition is named default" do it "returns the first target of the project if the target definition is named default" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new
user_project.new_target(:application, 'FirstTarget', :ios) user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'UserTarget', :ios) user_project.new_target(:application, 'UserTarget', :ios)
......
...@@ -10,7 +10,7 @@ module Pod ...@@ -10,7 +10,7 @@ module Pod
platform :ios platform :ios
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions[:default] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox.project_path)
config.sandbox.project = @project config.sandbox.project = @project
......
...@@ -9,7 +9,8 @@ module Pod ...@@ -9,7 +9,8 @@ module Pod
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path @sample_project = Xcodeproj::Project.new sample_project_path
@target = @sample_project.targets.first @target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true
@lib = Library.new(target_definition) @lib = Library.new(target_definition)
@lib.user_project_path = sample_project_path @lib.user_project_path = sample_project_path
pods_project = Project.new() pods_project = Project.new()
......
...@@ -17,7 +17,7 @@ module Pod ...@@ -17,7 +17,7 @@ module Pod
end end
end end
config.sandbox.project = Project.new() config.sandbox.project = Project.new()
@library = Library.new(@podfile.target_definitions[:default]) @library = Library.new(@podfile.target_definitions['Pods'])
@library.user_project_path = sample_project_path @library.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870'] @library.user_target_uuids = ['A346496C14F9BE9A0080D870']
@library.support_files_root = config.sandbox.root @library.support_files_root = config.sandbox.root
......
...@@ -5,7 +5,8 @@ module Pod ...@@ -5,7 +5,8 @@ module Pod
describe "In general" do describe "In general" do
before do before do
@target_definition = Podfile::TargetDefinition.new(:default, nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@lib = Library.new(@target_definition) @lib = Library.new(@target_definition)
end end
...@@ -28,7 +29,8 @@ module Pod ...@@ -28,7 +29,8 @@ module Pod
describe "Support files" do describe "Support files" do
before do before do
@target_definition = Podfile::TargetDefinition.new(:default, nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true
@lib = Library.new(@target_definition) @lib = Library.new(@target_definition)
@lib.support_files_root = config.sandbox.root @lib.support_files_root = config.sandbox.root
@lib.user_project_path = config.sandbox.root + '../user_project.xcodeproj' @lib.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
......
...@@ -27,7 +27,7 @@ module Pod ...@@ -27,7 +27,7 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "resolves the specification of the podfile" do it "resolves the specification of the podfile" do
target_definition = @podfile.target_definitions[:default] target_definition = @podfile.target_definitions['Pods']
specs = @resolver.resolve[target_definition] specs = @resolver.resolve[target_definition]
specs.map(&:to_s).should == [ specs.map(&:to_s).should == [
"A2DynamicDelegate (2.0.2)", "A2DynamicDelegate (2.0.2)",
...@@ -38,7 +38,7 @@ module Pod ...@@ -38,7 +38,7 @@ module Pod
it "returns the resolved specifications grouped by target definition" do it "returns the resolved specifications grouped by target definition" do
@resolver.resolve @resolver.resolve
target_definition = @podfile.target_definitions[:default] target_definition = @podfile.target_definitions['Pods']
specs = @resolver.specs_by_target[target_definition] specs = @resolver.specs_by_target[target_definition]
specs.map(&:to_s).should == [ specs.map(&:to_s).should == [
"A2DynamicDelegate (2.0.2)", "A2DynamicDelegate (2.0.2)",
......
...@@ -96,7 +96,7 @@ module Pod ...@@ -96,7 +96,7 @@ module Pod
it "respects the local option" do it "respects the local option" do
validator = Validator.new(podspec_path) validator = Validator.new(podspec_path)
podfile = validator.send(:podfile_from_spec, :ios, '5.0') podfile = validator.send(:podfile_from_spec, :ios, '5.0')
deployment_target = podfile.target_definitions[:default].platform.deployment_target deployment_target = podfile.target_definitions['Pods'].platform.deployment_target
deployment_target.to_s.should == "5.0" deployment_target.to_s.should == "5.0"
end end
...@@ -114,7 +114,7 @@ module Pod ...@@ -114,7 +114,7 @@ module Pod
it "uses the deployment target of the specification" do it "uses the deployment target of the specification" do
validator = Validator.new(podspec_path) validator = Validator.new(podspec_path)
podfile = validator.send(:podfile_from_spec, :ios, '5.0') podfile = validator.send(:podfile_from_spec, :ios, '5.0')
dependency = podfile.target_definitions[:default].dependencies.first dependency = podfile.target_definitions['Pods'].dependencies.first
dependency.external_source.has_key?(:podspec).should.be.true dependency.external_source.has_key?(:podspec).should.be.true
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