Commit ace222ef authored by Eloy Duran's avatar Eloy Duran

Move ProjectTemplate code into Xcode::Project extension.

parent 738cf91b
...@@ -12,7 +12,6 @@ module Pod ...@@ -12,7 +12,6 @@ module Pod
autoload :Executable, 'cocoapods/executable' autoload :Executable, 'cocoapods/executable'
autoload :Installer, 'cocoapods/installer' autoload :Installer, 'cocoapods/installer'
autoload :Podfile, 'cocoapods/podfile' autoload :Podfile, 'cocoapods/podfile'
autoload :ProjectTemplate, 'cocoapods/project_template'
autoload :Resolver, 'cocoapods/resolver' autoload :Resolver, 'cocoapods/resolver'
autoload :Source, 'cocoapods/source' autoload :Source, 'cocoapods/source'
autoload :Spec, 'cocoapods/specification' autoload :Spec, 'cocoapods/specification'
...@@ -25,6 +24,7 @@ end ...@@ -25,6 +24,7 @@ end
module Xcode module Xcode
autoload :Config, 'cocoapods/xcode_project' autoload :Config, 'cocoapods/xcode_project'
autoload :Project, 'cocoapods/xcode_project' autoload :Project, 'cocoapods/xcode_project'
autoload :Workspace, 'cocoapods/xcode_project'
end end
class Pathname class Pathname
......
...@@ -164,7 +164,7 @@ EOS ...@@ -164,7 +164,7 @@ EOS
def project def project
return @project if @project return @project if @project
@project = ProjectTemplate.for_platform(@podfile.platform) @project = Xcode::Project.for_platform(@podfile.platform)
# First we need to resolve dependencies across *all* targets, so that the # First we need to resolve dependencies across *all* targets, so that the
# same correct versions of pods are being used for all targets. This # same correct versions of pods are being used for all targets. This
# happens when we call `build_specifications'. # happens when we call `build_specifications'.
......
require 'fileutils'
module Pod
module ProjectTemplate
def self.for_platform(platform)
project = Xcode::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
project.root_object.attributes['buildConfigurationList'] = project.objects.add(Xcode::Project::XCConfigurationList, {
'defaultConfigurationIsVisible' => '0',
'defaultConfigurationName' => 'Release',
'buildConfigurations' => [
project.objects.add(Xcode::Project::XCBuildConfiguration, {
'name' => 'Debug',
'buildSettings' => build_settings(platform, :debug)
}),
project.objects.add(Xcode::Project::XCBuildConfiguration, {
'name' => 'Release',
'buildSettings' => build_settings(platform, :release)
})
].map(&:uuid)
}).uuid
project
end
private
COMMON_BUILD_SETTINGS = {
:all => {
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
'GCC_C_LANGUAGE_STANDARD' => 'gnu99',
'INSTALL_PATH' => "$(BUILT_PRODUCTS_DIR)",
'GCC_WARN_ABOUT_MISSING_PROTOTYPES' => 'YES',
'GCC_WARN_ABOUT_RETURN_TYPE' => 'YES',
'GCC_WARN_UNUSED_VARIABLE' => 'YES',
'OTHER_LDFLAGS' => ''
},
:debug => {
'GCC_DYNAMIC_NO_PIC' => 'NO',
'GCC_PREPROCESSOR_DEFINITIONS' => ["DEBUG=1", "$(inherited)"],
'GCC_SYMBOLS_PRIVATE_EXTERN' => 'NO',
'GCC_OPTIMIZATION_LEVEL' => '0'
},
: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'
},
: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'
}
}
def self.build_settings(platform, scheme)
settings = COMMON_BUILD_SETTINGS[:all].merge(COMMON_BUILD_SETTINGS[platform])
settings['COPY_PHASE_STRIP'] = scheme == :debug ? 'NO' : 'YES'
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
settings
end
end
end
...@@ -20,5 +20,80 @@ module Xcode ...@@ -20,5 +20,80 @@ module Xcode
}) })
end end
end end
def self.for_platform(platform)
project = Xcode::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
project.root_object.attributes['buildConfigurationList'] = project.objects.add(Xcode::Project::XCConfigurationList, {
'defaultConfigurationIsVisible' => '0',
'defaultConfigurationName' => 'Release',
'buildConfigurations' => [
project.objects.add(Xcode::Project::XCBuildConfiguration, {
'name' => 'Debug',
'buildSettings' => build_settings(platform, :debug)
}),
project.objects.add(Xcode::Project::XCBuildConfiguration, {
'name' => 'Release',
'buildSettings' => build_settings(platform, :release)
})
].map(&:uuid)
}).uuid
project
end
private
COMMON_BUILD_SETTINGS = {
:all => {
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
'GCC_C_LANGUAGE_STANDARD' => 'gnu99',
'INSTALL_PATH' => "$(BUILT_PRODUCTS_DIR)",
'GCC_WARN_ABOUT_MISSING_PROTOTYPES' => 'YES',
'GCC_WARN_ABOUT_RETURN_TYPE' => 'YES',
'GCC_WARN_UNUSED_VARIABLE' => 'YES',
'OTHER_LDFLAGS' => ''
},
:debug => {
'GCC_DYNAMIC_NO_PIC' => 'NO',
'GCC_PREPROCESSOR_DEFINITIONS' => ["DEBUG=1", "$(inherited)"],
'GCC_SYMBOLS_PRIVATE_EXTERN' => 'NO',
'GCC_OPTIMIZATION_LEVEL' => '0'
},
: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'
},
: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'
}
}
def self.build_settings(platform, scheme)
settings = COMMON_BUILD_SETTINGS[:all].merge(COMMON_BUILD_SETTINGS[platform])
settings['COPY_PHASE_STRIP'] = scheme == :debug ? 'NO' : 'YES'
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
settings
end
end 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