Commit cb05af48 authored by Eloy Duran's avatar Eloy Duran

Make platform specific build settings specs work again.

parent 4e4fc7fb
......@@ -21,7 +21,7 @@ module Pod
def project
return @project if @project
# TODO this should not init with platform
@project = Pod::Project.for_platform(@podfile.target_definitions[:default].platform)
@project = Pod::Project.new
activated_pods.each do |pod|
# Add all source files to the project grouped by pod
group = @project.add_pod_group(pod.name)
......
......@@ -51,8 +51,7 @@ module Pod
def install!(pods, sandbox)
self.requires_arc = pods.any? { |pod| pod.requires_arc? }
# First add the target to the project
@target = @project.targets.new_static_library(@target_definition.platform.name, @target_definition.label)
@target = @project.add_pod_target(@target_definition.label, @target_definition.platform)
pods.each do |pod|
# TODO add methods like xcconfig to LocalPod as well? (which returns the correct platform)
......
......@@ -12,6 +12,10 @@ end
module Pod
class Project < Xcodeproj::Project
def initialize(*)
super
main_group << groups.new('name' => 'Pods')
end
# Shortcut access to the `Pods' PBXGroup.
def pods
......@@ -23,17 +27,21 @@ module Pod
pods.groups.new('name' => name)
end
# TODO do we need this?
def build_configuration(name)
build_configurations.find { |c| c.name == name }
end
def add_pod_target(name, platform)
target = targets.new_static_library(platform.name, name)
def self.for_platform(platform)
Pod::Project.new.tap do |project|
project.main_group << project.groups.new('name' => 'Pods')
project.build_settings('Debug').merge!(build_settings(platform))
project.build_settings('Release').merge!(build_settings(platform))
settings = {}
if platform.requires_legacy_ios_archs?
settings['ARCHS'] = "armv6 armv7"
end
if platform == :ios && platform.deployment_target
settings['IPHONEOS_DEPLOYMENT_TARGET'] = platform.deployment_target.to_s
end
target.build_settings('Debug').merge!(settings)
target.build_settings('Release').merge!(settings)
target
end
private
......
......@@ -11,7 +11,7 @@ describe Pod::Installer::TargetInstaller do
:generate_bridge_support? => false,
:set_arc_compatibility_flag? => false)
@project = Pod::Project.for_platform(platform)
@project = Pod::Project.new
@project.main_group.groups.new('name' => 'Targets Support Files')
@installer = Pod::Installer::TargetInstaller.new(@podfile, @project, @target_definition)
......
......@@ -33,58 +33,50 @@ describe 'Pod::Project' do
@project.targets.first.build_phases.should.include phase
end
shared "for any platform" do
it "adds a Debug and Release build configuration" do
@project.build_configurations.count.should == 2
@project.build_configurations.map(&:name).sort.should == %w{Debug Release}.sort
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)
target.build_settings('Release')["VALIDATE_PRODUCT"].should == "YES"
end
end
describe "for the :ios platform" do
describe "concerning its :ios targets with a deployment target" do
before do
@project = Pod::Project.for_platform(Pod::Platform.new(:ios))
end
behaves_like "for any platform"
xit "sets VALIDATE_PRODUCT to YES for the Release configuration" do
@project.build_configuration("Release").build_settings["VALIDATE_PRODUCT"].should == "YES"
end
@project = Pod::Project.new
end
describe "for the :ios platform with a deployment target" do
it "sets ARCHS to 'armv6 armv7' for both configurations if the deployment target is less than 4.3" do
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project.build_configuration("Debug").build_settings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").build_settings["ARCHS"].should == "armv6 armv7"
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios, :deployment_target => "4.0"))
target.build_settings('Debug')["ARCHS"].should == "armv6 armv7"
target.build_settings('Release')["ARCHS"].should == "armv6 armv7"
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.1"))
@project.build_configuration("Debug").build_settings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").build_settings["ARCHS"].should == "armv6 armv7"
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios, :deployment_target => "4.1"))
target.build_settings('Debug')["ARCHS"].should == "armv6 armv7"
target.build_settings('Release')["ARCHS"].should == "armv6 armv7"
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.2"))
@project.build_configuration("Debug").build_settings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").build_settings["ARCHS"].should == "armv6 armv7"
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios, :deployment_target => "4.2"))
target.build_settings('Debug')["ARCHS"].should == "armv6 armv7"
target.build_settings('Release')["ARCHS"].should == "armv6 armv7"
end
xit "uses standard ARCHs if deployment target is 4.3 or above" do
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.3"))
@project.build_configuration("Debug").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
it "uses standard ARCHs if deployment target is 4.3 or above" do
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios, :deployment_target => "4.3"))
target.build_settings('Debug')["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
target.build_settings('Release')["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.4"))
@project.build_configuration("Debug").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios, :deployment_target => "4.4"))
target.build_settings('Debug')["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
target.build_settings('Release')["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
end
xit "sets IPHONEOS_DEPLOYMENT_TARGET for both configurations" do
@project = Pod::Project.for_platform(Pod::Platform.new(:ios))
@project.build_configuration("Debug").build_settings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project.build_configuration("Release").build_settings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
it "sets IPHONEOS_DEPLOYMENT_TARGET for both configurations" do
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios))
target.build_settings('Debug')["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
target.build_settings('Release')["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project.build_configuration("Debug").build_settings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
@project.build_configuration("Release").build_settings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
target = @project.add_pod_target('Pods', Pod::Platform.new(:ios, :deployment_target => "4.0"))
target.build_settings('Debug')["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
target.build_settings('Release')["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
end
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