Permalink
Browse files

Add build configurations to the Pods targets based on Debug and Release.

  • Loading branch information...
1 parent c46a4c1 commit a0a15ccc7ee8bdff983b62ee024533a7aa479e26 @alloy alloy committed May 6, 2012
Showing with 22 additions and 3 deletions.
  1. +14 −2 lib/cocoapods/project.rb
  2. +8 −1 spec/unit/project_spec.rb
@@ -15,10 +15,14 @@ class Project < Xcodeproj::Project
def initialize(*)
super
main_group << groups.new('name' => 'Pods')
+ @user_build_configurations = []
end
- def add_build_configurations(user_configurations)
- user_configurations.each do |name, _|
+ def user_build_configurations=(user_build_configurations)
+ @user_build_configurations = user_build_configurations
+ # The configurations at the top level only need to exist, they don't hold
+ # any build settings themselves, that's left to `add_pod_target`.
+ user_build_configurations.each do |name, _|
unless build_configurations.map(&:name).include?(name)
build_configurations.new('name' => name)
end
@@ -49,6 +53,14 @@ def add_pod_target(name, platform)
target.build_settings('Debug').merge!(settings)
target.build_settings('Release').merge!(settings)
+ @user_build_configurations.each do |name, type|
+ unless target.build_configurations.map(&:name).include?(name)
+ config = target.build_configurations.new('name' => name)
+ # Copy the settings from either the Debug or the Release configuration.
+ config.build_settings = target.build_settings(type.to_s.capitalize).merge(settings)
+ end
+ end
+
target
end
end
@@ -34,10 +34,17 @@ def find_object(conditions)
end
it "adds build configurations named after every configuration across all of the user's projects" do
- @project.add_build_configurations('Debug' => :debug, 'Release' => :release, 'Test' => :debug, 'AppStore' => :release)
+ @project.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'Test' => :debug, 'AppStore' => :release }
@project.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test }
end
+ it "adds build configurations named after every configuration across all of the user's projects to a target" do
+ @project.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'Test' => :debug, 'AppStore' => :release }
+ target = @project.add_pod_target('SomeTarget', Pod::Platform.ios)
+ target.build_settings('Test')["VALIDATE_PRODUCT"].should == nil
+ target.build_settings('AppStore')["VALIDATE_PRODUCT"].should == "YES"
+ end
+
describe "concerning its :ios targets" do
it "sets VALIDATE_PRODUCT to YES for the Release configuration" do
target = Pod::Project.new.add_pod_target('Pods', Pod::Platform.ios)

0 comments on commit a0a15cc

Please sign in to comment.