Commit c46a4c1b authored by Eloy Duran's avatar Eloy Duran

Read the configurations from the user's projects and default to :release.

parent 660d5a61
...@@ -5,16 +5,16 @@ module Pod ...@@ -5,16 +5,16 @@ module Pod
DEFAULT_BUILD_CONFIGURATIONS = { 'Debug' => :debug, 'Release' => :release }.freeze DEFAULT_BUILD_CONFIGURATIONS = { 'Debug' => :debug, 'Release' => :release }.freeze
attr_reader :build_configurations
def initialize(path = nil, build_configurations = {}) def initialize(path = nil, build_configurations = {})
self.path = path if path self.path = path if path
@build_configurations = build_configurations.merge(DEFAULT_BUILD_CONFIGURATIONS) @build_configurations = build_configurations.merge(DEFAULT_BUILD_CONFIGURATIONS)
end end
def path=(path) def path=(path)
path = path.to_s path = path.to_s
@path = config.project_root + (File.extname(path) == '.xcodeproj' ? path : "#{path}.xcodeproj") @path = Pathname.new(File.extname(path) == '.xcodeproj' ? path : "#{path}.xcodeproj")
@path = config.project_root + @path unless @path.absolute?
@path
end end
def path def path
...@@ -27,6 +27,20 @@ module Pod ...@@ -27,6 +27,20 @@ module Pod
end end
end end
end end
def project
Xcodeproj::Project.new(path) if path
end
def build_configurations
if project
project.build_configurations.map(&:name).inject({}) do |hash, name|
hash[name] = :release; hash
end.merge(@build_configurations)
else
@build_configurations
end
end
end end
class TargetDefinition class TargetDefinition
......
...@@ -248,7 +248,8 @@ describe "Pod::Podfile" do ...@@ -248,7 +248,8 @@ describe "Pod::Podfile" do
@podfile.target_definitions[:nested_osx_target].should.not.be.exclusive @podfile.target_definitions[:nested_osx_target].should.not.be.exclusive
end end
it "returns the custom configurations, that the user's project contains, and wether it should be based on a debug or a release build" do it "returns the specified configurations and wether it should be based on a debug or a release build" do
Pod::Podfile::UserProject.any_instance.stubs(:project)
all = { 'Release' => :release, 'Debug' => :debug, 'Test' => :debug } all = { 'Release' => :release, 'Debug' => :debug, 'Test' => :debug }
@podfile.target_definitions[:default].user_project.build_configurations.should == all.merge('iOS App Store' => :release) @podfile.target_definitions[:default].user_project.build_configurations.should == all.merge('iOS App Store' => :release)
@podfile.target_definitions[:test].user_project.build_configurations.should == all.merge('iOS App Store' => :release) @podfile.target_definitions[:test].user_project.build_configurations.should == all.merge('iOS App Store' => :release)
...@@ -257,6 +258,11 @@ describe "Pod::Podfile" do ...@@ -257,6 +258,11 @@ describe "Pod::Podfile" do
@podfile.user_build_configurations.should == all.merge('iOS App Store' => :release, 'Mac App Store' => :release) @podfile.user_build_configurations.should == all.merge('iOS App Store' => :release, 'Mac App Store' => :release)
end end
it "defaults, for unspecified configurations, to a release build" do
project = Pod::Podfile::UserProject.new(fixture('SampleProject/SampleProject.xcodeproj'), 'Test' => :debug)
project.build_configurations.should == { 'Release' => :release, 'Debug' => :debug, 'Test' => :debug, 'App Store' => :release }
end
describe "with an Xcode project that's not in the project_root" do describe "with an Xcode project that's not in the project_root" do
before do before do
@target_definition = @podfile.target_definitions[:default] @target_definition = @podfile.target_definitions[:default]
......
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