Skip to content

Commit

Permalink
Merge branch 'master' into 1-1-stable
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
mrackwitz committed May 31, 2016
2 parents ad86a33 + cd03f25 commit f293b1e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

##### Enhancements

* None.
* Add test target and extension target helpers to `PBXNativeTarget`.
[Samuel Giddins](https://github.com/segiddins)

##### Bug Fixes

Expand Down
26 changes: 23 additions & 3 deletions lib/xcodeproj/project/object/native_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,29 @@ class PBXNativeTarget < AbstractTarget
# @return [Symbol] The type of the target expressed as a symbol.
#
def symbol_type
pair = Constants::PRODUCT_TYPE_UTI.find { |_key, value| value == product_type }
return nil if pair.nil?
pair.first
Constants::PRODUCT_TYPE_UTI.key(product_type)
end

# @return [Boolean] Whether the target is a test target.
#
def test_target_type?
case symbol_type
when :octest_bundle, :unit_test_bundle, :ui_test_bundle
true
else
false
end
end

# @return [Boolean] Whether the target is an extension.
#
def extension_target_type?
case symbol_type
when :app_extension, :watch_extension, :watch2_extension, :tv_extension
true
else
false
end
end

# Adds source files to the target.
Expand Down
39 changes: 39 additions & 0 deletions spec/project/object/native_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,45 @@ module ProjectSpecs
end
end

describe '#test_target_type?' do
it 'returns true for test target types' do
@target.stubs(:symbol_type => :octest_bundle)
@target.should.be.test_target_type

@target.stubs(:symbol_type => :unit_test_bundle)
@target.should.be.test_target_type

@target.stubs(:symbol_type => :ui_test_bundle)
@target.should.be.test_target_type
end

it 'returns false for non-test target types' do
@target.stubs(:symbol_type => :application)
@target.should.not.be.test_target_type
end
end

describe '#extension_target_type?' do
it 'returns true for extension target types' do
@target.stubs(:symbol_type => :app_extension)
@target.should.be.extension_target_type

@target.stubs(:symbol_type => :watch_extension)
@target.should.be.extension_target_type

@target.stubs(:symbol_type => :watch2_extension)
@target.should.be.extension_target_type

@target.stubs(:symbol_type => :tv_extension)
@target.should.be.extension_target_type
end

it 'returns false for non-extension target types' do
@target.stubs(:symbol_type => :application)
@target.should.not.be.extension_target_type
end
end

it 'adds a list of source files to the target to the source build phase' do
ref = @project.main_group.new_file('Class.m')
@target.add_file_references([ref], '-fobjc-arc')
Expand Down

0 comments on commit f293b1e

Please sign in to comment.