Commit 9ea008e3 authored by Eloy Duran's avatar Eloy Duran

Clean template related code a bit by using the API.

parent 9ee4b9b5
...@@ -212,26 +212,17 @@ module Pod ...@@ -212,26 +212,17 @@ module Pod
config.baseConfiguration = configfile config.baseConfiguration = configfile
end end
end end
app_project.main_group << configfile
libfile = app_project.files.new({ libfile = app_project.files.new_static_library('Pods')
'path' => 'libPods.a',
'lastKnownFileType' => 'archive.ar',
'includeInIndex' => '0',
'sourceTree' => 'BUILT_PRODUCTS_DIR'
})
app_project.objects.select_by_class(Xcode::Project::PBXFrameworksBuildPhase).each do |build_phase| app_project.objects.select_by_class(Xcode::Project::PBXFrameworksBuildPhase).each do |build_phase|
build_phase.files << libfile.buildFiles.new build_phase.files << libfile.buildFiles.new
end end
app_project.main_group << libfile
copy_resources = app_project.objects.add(Xcode::Project::PBXShellScriptBuildPhase, { copy_resources = app_project.objects.add(Xcode::Project::PBXShellScriptBuildPhase, {
'name' => 'Copy Pods Resources', 'name' => 'Copy Pods Resources',
'buildActionMask' => '2147483647',
'files' => [], 'files' => [],
'inputPaths' => [], 'inputPaths' => [],
'outputPaths' => [], 'outputPaths' => [],
'runOnlyForDeploymentPostprocessing' => '0',
'shellPath' => '/bin/sh', 'shellPath' => '/bin/sh',
'shellScript' => "${SRCROOT}/Pods/Pods-resources.sh\n" 'shellScript' => "${SRCROOT}/Pods/Pods-resources.sh\n"
}) })
......
...@@ -10,31 +10,22 @@ module Pod ...@@ -10,31 +10,22 @@ module Pod
'developmentRegion' => 'English', 'developmentRegion' => 'English',
'hasScannedForEncodings' => '0', 'hasScannedForEncodings' => '0',
'knownRegions' => ['en'], 'knownRegions' => ['en'],
'mainGroup' => project.groups.new({ 'sourceTree' => '<group>' }).uuid, 'mainGroup' => project.groups.new.uuid,
'projectDirPath' => '', 'projectDirPath' => '',
'projectRoot' => '', 'projectRoot' => '',
'targets' => [] 'targets' => []
}) })
project.root_object = root project.root_object = root
project.main_group << project.groups.new({ project.main_group << project.groups.new('name' => 'Pods')
'name' => 'Pods',
'sourceTree' => '<group>'
})
framework = project.files.new({ framework = project.files.new({
'lastKnownFileType' => 'wrapper.framework', 'lastKnownFileType' => 'wrapper.framework',
'name' => platform == :ios ? 'Foundation.framework' : 'Cocoa.framework', 'name' => platform == :ios ? 'Foundation.framework' : 'Cocoa.framework',
'path' => "System/Library/Frameworks/#{platform == :ios ? 'Framework' : 'Cocoa'}.framework", 'path' => "System/Library/Frameworks/#{platform == :ios ? 'Framework' : 'Cocoa'}.framework",
'sourceTree' => 'SDKROOT' 'sourceTree' => 'SDKROOT'
}) })
framework.group = project.groups.new({ framework.group = project.groups.new('name' => 'Frameworks')
'name' => 'Frameworks',
'sourceTree' => '<group>'
})
project.main_group << framework.group project.main_group << framework.group
products = project.groups.new({ products = project.groups.new('name' => 'Products')
'name' => 'Products',
'sourceTree' => '<group>'
})
project.main_group << products project.main_group << products
project.root_object.products = products project.root_object.products = products
......
...@@ -238,6 +238,15 @@ module Pod ...@@ -238,6 +238,15 @@ module Pod
has_many :buildFiles, :inverse_of => :file has_many :buildFiles, :inverse_of => :file
has_one :group, :inverse_of => :children has_one :group, :inverse_of => :children
def self.new_static_library(project, productName)
new(project, nil, {
"path" => "lib#{productName}.a",
"includeInIndex" => "0", # no idea what this is
"explicitFileType" => "archive.ar",
"sourceTree" => "BUILT_PRODUCTS_DIR",
})
end
def initialize(project, uuid, attributes) def initialize(project, uuid, attributes)
is_new = uuid.nil? is_new = uuid.nil?
super super
...@@ -359,9 +368,7 @@ module Pod ...@@ -359,9 +368,7 @@ module Pod
def self.new_static_library(project, productName) def self.new_static_library(project, productName)
# TODO should probably switch the uuid and attributes argument # TODO should probably switch the uuid and attributes argument
target = new(project, nil, 'productType' => STATIC_LIBRARY, 'productName' => productName) target = new(project, nil, 'productType' => STATIC_LIBRARY, 'productName' => productName)
target.product.path = "lib#{productName}.a" target.product = project.files.new_static_library(productName)
target.product.includeInIndex = "0" # no idea what this is
target.product.explicitFileType = "archive.ar"
target.buildPhases.add(PBXSourcesBuildPhase) target.buildPhases.add(PBXSourcesBuildPhase)
buildPhase = target.buildPhases.add(PBXFrameworksBuildPhase) buildPhase = target.buildPhases.add(PBXFrameworksBuildPhase)
...@@ -373,6 +380,8 @@ module Pod ...@@ -373,6 +380,8 @@ module Pod
target target
end end
# You need to specify a product. For a static library you can use
# PBXFileReference.new_static_library.
def initialize(project, *) def initialize(project, *)
super super
self.name ||= productName self.name ||= productName
...@@ -386,11 +395,12 @@ module Pod ...@@ -386,11 +395,12 @@ module Pod
buildConfigurationList.buildConfigurations.new('name' => 'Debug') buildConfigurationList.buildConfigurations.new('name' => 'Debug')
buildConfigurationList.buildConfigurations.new('name' => 'Release') buildConfigurationList.buildConfigurations.new('name' => 'Release')
end end
end
unless product alias_method :_product=, :product=
self.product = project.files.new('sourceTree' => 'BUILT_PRODUCTS_DIR') def product=(product)
product.group = project.products self._product = product
end product.group = @project.products
end end
def buildConfigurations def buildConfigurations
......
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