Skip to content

Commit

Permalink
[AbstractTarget] Document and clean up #add_build_configuration behav…
Browse files Browse the repository at this point in the history
…iour
  • Loading branch information
fabiopelosin committed Oct 11, 2013
1 parent a7e4033 commit 137c227
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/xcodeproj/project/object/native_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def build_configurations
end

# Adds a new build configuration to the target and populates its with
# default settings according to the provided type.
# default settings according to the provided type if one doesn't
# exists.
#
# @note If a build configuration with the given name is already
# present no new build configuration is added.
Expand All @@ -136,8 +137,13 @@ def build_configurations
# The type of the build configuration used to populate the build
# settings, must be :debug or :release.
#
def add_build_configuration(name, type, skip_existing_names = true)
unless build_configuration_list[name]
# @return [XCBuildConfiguration] the created build configuration or the
# existing one with the same name.
#
def add_build_configuration(name, type)
if existing = build_configuration_list[name]
existing
else
build_configuration = project.new(XCBuildConfiguration)
build_configuration.name = name
build_configuration.build_settings = ProjectHelper.common_build_settings(type, platform_name, deployment_target, product_type)
Expand Down
11 changes: 11 additions & 0 deletions spec/project/object/native_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ module ProjectSpecs
@sut.build_configurations.map(&:name).grep('App Store').size.should == 1
end

it "returns the new build configuration" do
conf = @sut.add_build_configuration('App Store', :release)
conf.name.should == 'App Store'
end

it "returns the existing build configuration" do
conf_1 = @sut.add_build_configuration('App Store', :release)
conf_2 = @sut.add_build_configuration('App Store', :release)
conf_1.object_id.should == conf_2.object_id
end

end

#----------------------------------------#
Expand Down

0 comments on commit 137c227

Please sign in to comment.