Commit 7fa98144 authored by Eloy Durán's avatar Eloy Durán

Merge pull request #1294 from CocoaPods/0xced/copy-user_project-build_configurations

Pass the user build configurations to the Pods project
parents 80b0dc9c 63c80b18
...@@ -17,7 +17,7 @@ GIT ...@@ -17,7 +17,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: e2a6fb7466b26c3628c726271be60700bc635a62 revision: 9d2f8cef72466cb3f155a9a5a3cfb12c94802656
branch: master branch: master
specs: specs:
xcodeproj (0.9.0) xcodeproj (0.9.0)
......
...@@ -220,6 +220,7 @@ namespace :spec do ...@@ -220,6 +220,7 @@ namespace :spec do
title 'Running the specs' title 'Running the specs'
sh "bundle exec bacon #{specs('**')}" sh "bundle exec bacon #{specs('**')}"
require 'pathname'
unless Pathname.new(ENV['HOME']+'/.cocoapods/repos/master').exist? unless Pathname.new(ENV['HOME']+'/.cocoapods/repos/master').exist?
title 'Ensuring specs repo is up to date' title 'Ensuring specs repo is up to date'
sh "./bin/pod setup" sh "./bin/pod setup"
...@@ -343,7 +344,8 @@ namespace :examples do ...@@ -343,7 +344,8 @@ namespace :examples do
Dir.chdir(example.to_s) do Dir.chdir(example.to_s) do
execute_command "rm -rf Pods DerivedData" execute_command "rm -rf Pods DerivedData"
# WARNING: This appeart to use sytem gems instead of the bundle ones. # WARNING: This appeart to use sytem gems instead of the bundle ones.
execute_command "#{'../../bin/' unless ENV['FROM_GEM']}sandbox-pod install --verbose --no-repo-update" pod_command = ENV['FROM_GEM'] ? 'sandbox-pod' : 'bundle exec ../../bin/sandbox-pod'
execute_command "#{pod_command} install --verbose --no-repo-update"
command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'" command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'"
if (example + 'Podfile').read.include?('platform :ios') if (example + 'Podfile').read.include?('platform :ios')
# Specifically build against the simulator SDK so we don't have to deal with code signing. # Specifically build against the simulator SDK so we don't have to deal with code signing.
......
...@@ -6,7 +6,7 @@ module Pod ...@@ -6,7 +6,7 @@ module Pod
self.summary = 'Setup the CocoaPods environment' self.summary = 'Setup the CocoaPods environment'
self.description = <<-DESC self.description = <<-DESC
Creates a directory at `~/.cocoapods` which will hold your spec-repos. Creates a directory at `~/.cocoapods/repos` which will hold your spec-repos.
This is where it will create a clone of the public `master` spec-repo from: This is where it will create a clone of the public `master` spec-repo from:
https://github.com/CocoaPods/Specs https://github.com/CocoaPods/Specs
......
...@@ -285,7 +285,7 @@ module Pod ...@@ -285,7 +285,7 @@ module Pod
# #
def prepare_pods_project def prepare_pods_project
UI.message "- Creating Pods project" do UI.message "- Creating Pods project" do
@pods_project = Pod::Project.new(sandbox) @pods_project = Pod::Project.new(sandbox, analysis_result.all_user_build_configurations)
if config.podfile_path if config.podfile_path
@pods_project.add_podfile(config.podfile_path) @pods_project.add_podfile(config.podfile_path)
end end
......
...@@ -488,6 +488,16 @@ module Pod ...@@ -488,6 +488,16 @@ module Pod
# #
attr_accessor :targets attr_accessor :targets
# @return [Hash{String=>Symbol}] A hash representing all the user build
# configurations across all integration targets. Each key
# corresponds to the name of a configuration and its value to
# its type (`:debug` or `:release`).
#
def all_user_build_configurations
targets.inject({}) do |result, target|
result.merge(target.user_build_configurations)
end
end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -17,8 +17,8 @@ module Pod ...@@ -17,8 +17,8 @@ module Pod
# @param [Sandbox] sandbox @see #sandbox # @param [Sandbox] sandbox @see #sandbox
# #
def initialize(sandbox) def initialize(sandbox, build_configurations)
super(nil) # Recreate the project from scratch for now. super(nil, build_configurations) # Recreate the project from scratch for now.
# TODO # TODO
raise unless sandbox.is_a?(Sandbox) raise unless sandbox.is_a?(Sandbox)
@sandbox = sandbox @sandbox = sandbox
......
Subproject commit e5a4609aee415fe4588fd08eb9eebe6a8b7c707c Subproject commit fa5c727b65b4499b39d981685f93fc6369f46489
...@@ -89,7 +89,7 @@ module Pod ...@@ -89,7 +89,7 @@ module Pod
target.user_target_uuids.should == ["A346496C14F9BE9A0080D870"] target.user_target_uuids.should == ["A346496C14F9BE9A0080D870"]
user_proj = Xcodeproj::Project.new(target.user_project_path) user_proj = Xcodeproj::Project.new(target.user_project_path)
user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject' user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject'
target.user_build_configurations.should == {"Test"=>:release, "App Store"=>:release} target.user_build_configurations.should == { "Test" => :release, "App Store" => :release }
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
...@@ -103,6 +103,12 @@ module Pod ...@@ -103,6 +103,12 @@ module Pod
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
it "returns all the configurations the user has in any of its projects and/or targets" do
target_definition = @analyzer.podfile.target_definition_list.first
target_definition.stubs(:build_configurations).returns("AdHoc" => :test)
@analyzer.analyze.all_user_build_configurations.should == { "AdHoc" => :test, "Test" => :release, "App Store" => :release }
end
#--------------------------------------# #--------------------------------------#
it "locks the version of the dependencies which did not change in the Podfile" do it "locks the version of the dependencies which did not change in the Podfile" do
...@@ -314,7 +320,6 @@ module Pod ...@@ -314,7 +320,6 @@ module Pod
configurations.should == { 'AppStore' => :release } configurations.should == { 'AppStore' => :release }
end end
it "returns the user build configurations specified in the target definition" do it "returns the user build configurations specified in the target definition" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.build_configurations = { 'AppStore' => :release } target_definition.build_configurations = { 'AppStore' => :release }
......
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([], nil, config.sandbox) @pod_target = PodTarget.new([], nil, config.sandbox)
@pod_target.file_accessors = [@file_accessor] @pod_target.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project) @installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project)
end end
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -9,7 +9,8 @@ module Pod ...@@ -9,7 +9,8 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox) user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@project = Project.new(config.sandbox, user_build_configurations)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
...@@ -19,7 +20,7 @@ module Pod ...@@ -19,7 +20,7 @@ module Pod
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@pod_target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug } @pod_target.user_build_configurations = user_build_configurations
@pod_target.file_accessors = [file_accessor] @pod_target.file_accessors = [file_accessor]
@installer = Installer::PodTargetInstaller.new(config.sandbox, @pod_target) @installer = Installer::PodTargetInstaller.new(config.sandbox, @pod_target)
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
end end
end end
config.sandbox.project = Project.new(config.sandbox) config.sandbox.project = Project.new(config.sandbox, nil)
Xcodeproj::Project.new.save_as(config.sandbox.project_path) Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@library.client_root = sample_project_path.dirname @library.client_root = sample_project_path.dirname
......
...@@ -16,7 +16,7 @@ end ...@@ -16,7 +16,7 @@ end
def generate_podfile(pods = ['JSONKit']) def generate_podfile(pods = ['JSONKit'])
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform :ios platform :ios
xcodeproj 'SampleProject/SampleProject' xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release
pods.each { |name| pod name } pods.each { |name| pod name }
end end
end end
...@@ -112,7 +112,7 @@ module Pod ...@@ -112,7 +112,7 @@ module Pod
@installer.pod_targets.map(&:name).sort.should == ['Pods-JSONKit'] @installer.pod_targets.map(&:name).sort.should == ['Pods-JSONKit']
end end
it "configures the analizer to use update mode if appropriate" do it "configures the analyzer to use update mode if appropriate" do
@installer.update_mode = true @installer.update_mode = true
Installer::Analyzer.any_instance.expects(:update_mode=).with(true) Installer::Analyzer.any_instance.expects(:update_mode=).with(true)
@installer.send(:analyze) @installer.send(:analyze)
...@@ -217,14 +217,37 @@ module Pod ...@@ -217,14 +217,37 @@ module Pod
describe "#prepare_pods_project" do describe "#prepare_pods_project" do
it "creates the Pods project" do before do
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
end
it "creates build configurations for all of the user's targets" do
config.integrate_targets = true
@installer.send(:analyze)
@installer.send(:prepare_pods_project)
@installer.pods_project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test']
end
it "sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project" do
config.integrate_targets = true
@installer.send(:analyze)
@installer.send(:prepare_pods_project)
@installer.pods_project.build_settings('Debug')["STRIP_INSTALLED_PRODUCT"].should == "NO"
@installer.pods_project.build_settings('Test')["STRIP_INSTALLED_PRODUCT"].should == "NO"
@installer.pods_project.build_settings('Release')["STRIP_INSTALLED_PRODUCT"].should == "NO"
@installer.pods_project.build_settings('App Store')["STRIP_INSTALLED_PRODUCT"].should == "NO"
end
before do
@installer.stubs(:analysis_result).returns(stub(:all_user_build_configurations => {}))
end
it "creates the Pods project" do
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project.class.should == Pod::Project @installer.pods_project.class.should == Pod::Project
end end
it "adds the Podfile to the Pods project" do it "adds the Podfile to the Pods project" do
@installer.stubs(:aggregate_targets).returns([])
config.stubs(:podfile_path).returns(Pathname.new('/Podfile')) config.stubs(:podfile_path).returns(Pathname.new('/Podfile'))
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project['Podfile'].should.be.not.nil @installer.pods_project['Podfile'].should.be.not.nil
...@@ -243,6 +266,7 @@ module Pod ...@@ -243,6 +266,7 @@ module Pod
build_setting["IPHONEOS_DEPLOYMENT_TARGET"].should == '6.0' build_setting["IPHONEOS_DEPLOYMENT_TARGET"].should == '6.0'
end end
end end
end end
#--------------------------------------# #--------------------------------------#
...@@ -308,6 +332,7 @@ module Pod ...@@ -308,6 +332,7 @@ module Pod
before do before do
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
@installer.stubs(:analysis_result).returns(stub(:all_user_build_configurations => {}))
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
end end
......
...@@ -4,7 +4,7 @@ module Pod ...@@ -4,7 +4,7 @@ module Pod
describe Project do describe Project do
before do before do
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
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