Skip to content

Commit

Permalink
Merge commit '96da037af547efcef14d3f65f23cc41939143f63'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashton-W committed Aug 25, 2013
2 parents 77bcf03 + 96da037 commit 188c002
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 9 additions & 5 deletions lib/xcodeproj/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class Project
# @param [Pathname, String] xcodeproj
# The path to the Xcode project document (xcodeproj).
#
# @param [Hash {String => Symbol}] build_configurations
# Extra build configurations. The symbol must be :debug or :release
#
# @raise If the project versions are more recent than the ones know to
# Xcodeproj to prevent it from corrupting existing projects.
# Naturally, this would never happen with a project generated by
Expand All @@ -79,7 +82,8 @@ class Project
# @example Opening a project
# Project.new("path/to/Project.xcodeproj")
#
def initialize(xcodeproj = nil)
def initialize(xcodeproj = nil, build_configurations = nil)
build_configurations = { 'Debug' => :debug, 'Release' => :release }.merge(build_configurations || {})
@objects_by_uuid = {}
@generated_uuids = []
@available_uuids = []
Expand Down Expand Up @@ -116,10 +120,10 @@ def initialize(xcodeproj = nil)
config_list.default_configuration_is_visible = '0'
root_object.build_configuration_list = config_list

%w| Release Debug |.each do |name|
build_configurations.each do |name, name_sym|
build_configuration = new(XCBuildConfiguration)
build_configuration.name = name
build_configuration.build_settings = Constants::PROJECT_DEFAULT_BUILD_SETTINGS[name.downcase.to_sym].dup
build_configuration.build_settings = Constants::PROJECT_DEFAULT_BUILD_SETTINGS[name_sym].dup
config_list.build_configurations << build_configuration
end

Expand Down Expand Up @@ -232,7 +236,7 @@ def pretty_print
{
'File References' => root_object.main_group.pretty_print.values.first,
'Targets' => root_object.targets.map(&:pretty_print),
'Build Configurations' => build_configurations.map(&:pretty_print)
'Build Configurations' => build_configurations.sort_by(&:name).map(&:pretty_print)
}
end

Expand All @@ -255,7 +259,7 @@ def save_as(projpath)
fix_encoding(file)
`which xcproj`
if $?.exitstatus.zero?
command = "xcproj --project #{projpath} touch"
command = "xcproj --project #{projpath} touch 2>&1"
output = `#{command}`
unless $?.exitstatus.zero?
message = "xcproj failed to touch the project. Check wether you installation of xcproj is functional.\n\n"
Expand Down
9 changes: 7 additions & 2 deletions spec/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ module ProjectSpecs
list.build_settings('Release').should == {}
end

it "initializes the default Debug and Release configurations plus the extra App Store and Test configurations" do
@project = Xcodeproj::Project.new(nil, { 'App Store' => :release, 'Test' => :debug })
@project.build_configurations.map(&:name).sort.should == [ 'App Store', 'Debug', 'Release', 'Test' ]
end

it "adds the frameworks group" do
@project['Frameworks'].class.should == PBXGroup
end
Expand Down Expand Up @@ -304,8 +309,8 @@ module ProjectSpecs
],
"Targets" => [],
"Build Configurations" => [
{ "Release" => {"Build Settings" => {} } },
{ "Debug" => {"Build Settings" => {} } }
{ "Debug" => {"Build Settings" => {} } },
{ "Release" => {"Build Settings" => {} } }
]
}
end
Expand Down

0 comments on commit 188c002

Please sign in to comment.