Commit 18abf36f authored by Marius Rackwitz's avatar Marius Rackwitz

Add methods to check if a target uses swift

parent c81a7b27
......@@ -96,6 +96,12 @@ module Pod
specs.map { |spec| spec.consumer(platform) }
end
# @return [Boolean] Whether the target uses Swift code
#
def uses_swift?
pod_targets.any?(&:uses_swift?)
end
#-------------------------------------------------------------------------#
# @!group Support files
......
......@@ -54,6 +54,14 @@ module Pod
specs.map { |spec| spec.consumer(platform) }
end
# @return [Boolean] Whether the target uses Swift code
#
def uses_swift?
file_accessors.any? do |file_accessor|
file_accessor.source_files.any? { |sf| sf.extname == ".swift" }
end
end
# @return [Specification] The root specification for the target.
#
def root_spec
......
......@@ -118,6 +118,15 @@ def fixture_file_accessor(name, platform = :ios)
Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
end
def fixture_pod_target(name, platform = :ios)
spec = fixture_spec(name)
target_definition = Pod::Podfile::TargetDefinition.new('Pods', nil)
Pod::PodTarget.new([spec], target_definition, config.sandbox).tap do |pod_target|
pod_target.stubs(:platform).returns(platform)
pod_target.file_accessors << fixture_file_accessor(name, platform)
end
end
#-----------------------------------------------------------------------------#
SpecHelper::Fixture.fixture('banana-lib') # ensure it exists
......
......@@ -115,5 +115,31 @@ module Pod
consumer_reps.should == [['BananaLib', :ios]]
end
end
describe 'Product type dependent helpers' do
describe 'With libraries' do
before do
@pod_target = fixture_pod_target('banana-lib/BananaLib.podspec')
@target = AggregateTarget.new(@pod_target.target_definition, config.sandbox)
@target.pod_targets = [@pod_target]
end
it 'returns that it does not use swift' do
@target.uses_swift?.should == false
end
end
describe 'With frameworks' do
before do
@pod_target = fixture_pod_target('orange-framework/OrangeFramework.podspec')
@target = AggregateTarget.new(@pod_target.target_definition, config.sandbox)
@target.pod_targets = [@pod_target]
end
it 'returns that it uses swift' do
@target.uses_swift?.should == true
end
end
end
end
end
......@@ -102,5 +102,27 @@ module Pod
end
end
describe 'Product type dependent helpers' do
describe 'With libraries' do
before do
@pod_target = fixture_pod_target('banana-lib/BananaLib.podspec')
end
it 'returns that it does not use swift' do
@pod_target.uses_swift?.should == false
end
end
describe 'With frameworks' do
before do
@pod_target = fixture_pod_target('orange-framework/OrangeFramework.podspec')
end
it 'returns that it uses swift' do
@pod_target.uses_swift?.should == true
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