Skip to content

Commit

Permalink
Fixes for the latest version of xcodeproj
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeredpath committed Mar 4, 2012
1 parent ce8650b commit 6e4ee6e
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 80 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Expand Up @@ -78,8 +78,8 @@ _before_ it’s written to disk. [[docs][3]]
# Enable garbage collection support for MacRuby applications.
post_install do |installer|
installer.project.targets.each do |target|
target.buildConfigurations.each do |config|
config.buildSettings['GCC_ENABLE_OBJC_GC'] = 'supported'
target.build_configurations.each do |config|
config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions examples/MacRubySample/Podfile
Expand Up @@ -16,8 +16,8 @@ end
# Enable garbage collection support, which MacRuby requires.
post_install do |installer|
installer.project.targets.each do |target|
target.buildConfigurations.each do |config|
config.buildSettings['GCC_ENABLE_OBJC_GC'] = 'supported'
target.build_configurations.each do |config|
config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
end
end
end
11 changes: 11 additions & 0 deletions lib/cocoapods/better_installer.rb
@@ -0,0 +1,11 @@
module Pod
class DependencyInstaller
def initialize(sandbox)
@sandbox = sandbox
end

def install(dependency)

end
end
end

This comment has been minimized.

Copy link
@lukeredpath

lukeredpath Mar 4, 2012

Author Contributor

Committed this by mistake, oops.

8 changes: 4 additions & 4 deletions lib/cocoapods/installer/target_installer.rb
Expand Up @@ -83,11 +83,11 @@ def install!(pods, sandbox)
end

def configure_build_configurations(xcconfig_file)
@target.buildConfigurations.each do |config|
@target.build_configurations.each do |config|
config.baseConfiguration = xcconfig_file
config.buildSettings['OTHER_LDFLAGS'] = ''
config.buildSettings['GCC_PREFIX_HEADER'] = prefix_header_filename
config.buildSettings['PODS_ROOT'] = '$(SRCROOT)'
config.build_settings['OTHER_LDFLAGS'] = ''
config.build_settings['GCC_PREFIX_HEADER'] = prefix_header_filename
config.build_settings['PODS_ROOT'] = '$(SRCROOT)'
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/cocoapods/podfile.rb
Expand Up @@ -206,8 +206,8 @@ def target(name, options = {})
#
# post_install do |installer|
# installer.project.targets.each do |target|
# target.buildConfigurations.each do |config|
# config.buildSettings['GCC_ENABLE_OBJC_GC'] = 'supported'
# target.build_configurations.each do |config|
# config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
# end
# end
# end
Expand Down
97 changes: 53 additions & 44 deletions lib/cocoapods/project.rb
Expand Up @@ -22,40 +22,46 @@ def add_pod_group(name)
pods.groups.new('name' => name)
end

def build_configuration_list
objects[root_object.attributes['buildConfigurationList']]
end

# Shortcut access to build configurations
def build_configurations
objects[root_object.attributes['buildConfigurationList']].buildConfigurations
build_configuration_list.build_configurations
end

def build_configuration(name)
build_configurations.find { |c| c.name == name }
end

def self.for_platform(platform)
project = Pod::Project.new
project.main_group << project.groups.new({ 'name' => 'Pods' })
framework = project.add_system_framework(platform == :ios ? 'Foundation' : 'Cocoa')
framework.group = project.groups.new({ 'name' => 'Frameworks' })
project.main_group << framework.group
products = project.groups.new({ 'name' => 'Products' })
project.main_group << products
project.root_object.products = products
Pod::Project.new.tap do |project|
project.main_group << project.groups.new({ 'name' => 'Pods' })
framework = project.add_system_framework(platform == :ios ? 'Foundation' : 'Cocoa')
framework.group = project.groups.new({ 'name' => 'Frameworks' })
project.main_group << framework.group
products = project.groups.new({ 'name' => 'Products' })
project.main_group << products
project.root_object.products = products

configuration_list = project.objects.add(Xcodeproj::Project::Object::XCConfigurationList, {
'defaultConfigurationIsVisible' => '0',
'defaultConfigurationName' => 'Release',
})

config = configuration_list.build_configurations.new(
'name' => 'Debug',
'buildSettings' => build_settings(platform, :debug)
)

configuration_list.build_configurations.new(
'name' => 'Release',
'buildSettings' => build_settings(platform, :release)
)

project.root_object.attributes['buildConfigurationList'] = project.objects.add(Xcodeproj::Project::Object::XCConfigurationList, {
'defaultConfigurationIsVisible' => '0',
'defaultConfigurationName' => 'Release',
'buildConfigurations' => [
project.objects.add(Xcodeproj::Project::Object::XCBuildConfiguration, {
'name' => 'Debug',
'buildSettings' => build_settings(platform, :debug)
}),
project.objects.add(Xcodeproj::Project::Object::XCBuildConfiguration, {
'name' => 'Release',
'buildSettings' => build_settings(platform, :release)
})
].map(&:uuid)
}).uuid
project
project.root_object.attributes['buildConfigurationList'] = configuration_list.uuid
end
end

private
Expand All @@ -69,47 +75,50 @@ def self.for_platform(platform)
'GCC_WARN_ABOUT_RETURN_TYPE' => 'YES',
'GCC_WARN_UNUSED_VARIABLE' => 'YES',
'OTHER_LDFLAGS' => ''
},
}.freeze,
:debug => {
'GCC_DYNAMIC_NO_PIC' => 'NO',
'GCC_PREPROCESSOR_DEFINITIONS' => ["DEBUG=1", "$(inherited)"],
'GCC_SYMBOLS_PRIVATE_EXTERN' => 'NO',
'GCC_OPTIMIZATION_LEVEL' => '0'
},
}.freeze,
:ios => {
'ARCHS' => "$(ARCHS_STANDARD_32_BIT)",
'GCC_VERSION' => 'com.apple.compilers.llvmgcc42',
'IPHONEOS_DEPLOYMENT_TARGET' => '4.3',
'PUBLIC_HEADERS_FOLDER_PATH' => "$(TARGET_NAME)",
'SDKROOT' => 'iphoneos'
},
}.freeze,
:osx => {
'ARCHS' => "$(ARCHS_STANDARD_64_BIT)",
'GCC_ENABLE_OBJC_EXCEPTIONS' => 'YES',
'GCC_WARN_64_TO_32_BIT_CONVERSION' => 'YES',
'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0',
'MACOSX_DEPLOYMENT_TARGET' => '10.7',
'SDKROOT' => 'macosx'
}
}
}.freeze
}.freeze

def self.build_settings(platform, scheme)
settings = COMMON_BUILD_SETTINGS[:all].merge(COMMON_BUILD_SETTINGS[platform.name])
settings['COPY_PHASE_STRIP'] = scheme == :debug ? 'NO' : 'YES'
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
if scheme == :debug
settings.merge!(COMMON_BUILD_SETTINGS[:debug])
settings['ONLY_ACTIVE_ARCH'] = 'YES' if platform == :osx
else
settings['VALIDATE_PRODUCT'] = 'YES' if platform == :ios
settings['DEBUG_INFORMATION_FORMAT'] = "dwarf-with-dsym" if platform == :osx
COMMON_BUILD_SETTINGS[:all].dup.tap do |settings|
settings.merge!(COMMON_BUILD_SETTINGS[platform.name])

settings['COPY_PHASE_STRIP'] = scheme == :debug ? 'NO' : 'YES'

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
if scheme == :debug
settings.merge!(COMMON_BUILD_SETTINGS[:debug])
settings['ONLY_ACTIVE_ARCH'] = 'YES' if platform == :osx
else
settings['VALIDATE_PRODUCT'] = 'YES' if platform == :ios
settings['DEBUG_INFORMATION_FORMAT'] = "dwarf-with-dsym" if platform == :osx
end
end
settings
end
end
end
4 changes: 2 additions & 2 deletions lib/cocoapods/project_integration.rb
Expand Up @@ -67,7 +67,7 @@ def project_already_integrated?(project)

def base_project_configurations_on_xcconfig(project, xcconfig_file)
project.targets.each do |target|
target.buildConfigurations.each do |config|
target.build_configurations.each do |config|
config.baseConfiguration = xcconfig_file
end
end
Expand All @@ -82,7 +82,7 @@ def add_pods_library_to_each_target_in_project(project, pods_library)
end

def add_copy_resources_script_phase_to_each_target_in_project(project, copy_resources_script_phase)
project.targets.each { |target| target.buildPhases << copy_resources_script_phase }
project.targets.each { |target| target.build_phases << copy_resources_script_phase }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functional/project_integration_spec.rb
Expand Up @@ -31,7 +31,7 @@
xcconfig_file = @sample_project.files.where(:path => "Pods/Pods.xcconfig")

@sample_project.targets.each do |target|
target.buildConfigurations.each do |config|
target.build_configurations.each do |config|
config.baseConfiguration.should == xcconfig_file
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/integration_spec.rb
Expand Up @@ -136,16 +136,16 @@ def should_successfully_perform(command)

post_install do |installer|
target = installer.project.targets.first
target.buildConfigurations.each do |config|
config.buildSettings['GCC_ENABLE_OBJC_GC'] = 'supported'
target.build_configurations.each do |config|
config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
end
end
end

SpecHelper::Installer.new(podfile).install!
project = Pod::Project.new(config.project_pods_root + 'Pods.xcodeproj')
project.targets.first.buildConfigurations.map do |config|
config.buildSettings['GCC_ENABLE_OBJC_GC']
project.targets.first.build_configurations.map do |config|
config.build_settings['GCC_ENABLE_OBJC_GC']
end.should == %w{ supported supported }
end

Expand Down Expand Up @@ -325,15 +325,15 @@ def should_successfully_perform(command)
project = Pod::Project.new(projpath)
libPods = project.files.find { |f| f.name == 'libPods.a' }
project.targets.each do |target|
target.buildConfigurations.each do |config|
target.build_configurations.each do |config|
config.baseConfiguration.path.should == 'Pods/Pods.xcconfig'
end

phase = target.frameworks_build_phases.first
phase.files.map { |buildFile| buildFile.file }.should.include libPods

# should be the last phase
target.buildPhases.last.shellScript.should == %{"${SRCROOT}/Pods/Pods-resources.sh"\n}
target.build_phases.last.shellScript.should == %{"${SRCROOT}/Pods/Pods-resources.sh"\n}
end
end

Expand Down
34 changes: 17 additions & 17 deletions spec/unit/project_spec.rb
Expand Up @@ -13,7 +13,7 @@ def find_object(conditions)

it "adds a group to the `Pods' group" do
group = @project.add_pod_group('JSONKit')
@project.pods.childReferences.should.include group.uuid
@project.pods.child_references.should.include group.uuid
find_object({
'isa' => 'PBXGroup',
'name' => 'JSONKit',
Expand All @@ -30,7 +30,7 @@ def find_object(conditions)
'dstPath' => 'Pods/Path/To/Source',
'name' => 'Copy SomePod Public Headers'
}).should.not == nil
@project.targets.first.buildPhases.should.include phase
@project.targets.first.build_phases.should.include phase
end

shared "for any platform" do
Expand All @@ -48,43 +48,43 @@ def find_object(conditions)
behaves_like "for any platform"

it "sets VALIDATE_PRODUCT to YES for the Release configuration" do
@project.build_configuration("Release").buildSettings["VALIDATE_PRODUCT"].should == "YES"
@project.build_configuration("Release").build_settings["VALIDATE_PRODUCT"].should == "YES"
end
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").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Debug").build_settings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").build_settings["ARCHS"].should == "armv6 armv7"

@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.1"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Debug").build_settings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").build_settings["ARCHS"].should == "armv6 armv7"

@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.2"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Debug").build_settings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").build_settings["ARCHS"].should == "armv6 armv7"
end

it "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").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Debug").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"

@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.4"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Debug").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").build_settings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
end

it "sets IPHONEOS_DEPLOYMENT_TARGET for both configurations" do
@project = Pod::Project.for_platform(Pod::Platform.new(:ios))
@project.build_configuration("Debug").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project.build_configuration("Release").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project.build_configuration("Debug").build_settings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project.build_configuration("Release").build_settings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"

@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project.build_configuration("Debug").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
@project.build_configuration("Release").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "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"
end
end
end

0 comments on commit 6e4ee6e

Please sign in to comment.