Commit 7d64004e authored by Nolan Waite's avatar Nolan Waite

PBXFileReference sets some file types

parent 17275eb8
...@@ -203,10 +203,7 @@ module Pod ...@@ -203,10 +203,7 @@ module Pod
app_project = Xcode::Project.new(projpath) app_project = Xcode::Project.new(projpath)
return if app_project.files.find { |file| file.path =~ /libPods\.a$/ } return if app_project.files.find { |file| file.path =~ /libPods\.a$/ }
configfile = app_project.files.new({ configfile = app_project.files.new('path' => 'Pods/Pods.xcconfig')
'path' => 'Pods/Pods.xcconfig',
'lastKnownFileType' => 'text.xcconfig'
})
app_project.targets.each do |target| app_project.targets.each do |target|
target.buildConfigurations.each do |config| target.buildConfigurations.each do |config|
config.baseConfiguration = configfile config.baseConfiguration = configfile
......
...@@ -234,7 +234,7 @@ module Pod ...@@ -234,7 +234,7 @@ module Pod
end end
class PBXFileReference < PBXObject class PBXFileReference < PBXObject
attributes :path, :sourceTree, :explicitFileType, :includeInIndex attributes :path, :sourceTree, :explicitFileType, :lastKnownFileType, :includeInIndex
has_many :buildFiles, :inverse_of => :file has_many :buildFiles, :inverse_of => :file
has_one :group, :inverse_of => :children has_one :group, :inverse_of => :children
...@@ -242,7 +242,6 @@ module Pod ...@@ -242,7 +242,6 @@ module Pod
new(project, nil, { new(project, nil, {
"path" => "lib#{productName}.a", "path" => "lib#{productName}.a",
"includeInIndex" => "0", # no idea what this is "includeInIndex" => "0", # no idea what this is
"explicitFileType" => "archive.ar",
"sourceTree" => "BUILT_PRODUCTS_DIR", "sourceTree" => "BUILT_PRODUCTS_DIR",
}) })
end end
...@@ -255,6 +254,7 @@ module Pod ...@@ -255,6 +254,7 @@ module Pod
if is_new if is_new
@project.main_group.children << self @project.main_group.children << self
end end
set_default_file_type!
end end
alias_method :_path=, :path= alias_method :_path=, :path=
...@@ -267,6 +267,18 @@ module Pod ...@@ -267,6 +267,18 @@ module Pod
def pathname def pathname
Pathname.new(path) Pathname.new(path)
end end
def set_default_file_type!
return if explicitFileType || lastKnownFileType
case path
when /\.a$/
self.explicitFileType = 'archive.ar'
when /\.framework$/
self.lastKnownFileType = 'wrapper.framework'
when /\.xcconfig$/
self.lastKnownFileType = 'text.xcconfig'
end
end
end end
class PBXGroup < PBXObject class PBXGroup < PBXObject
...@@ -620,7 +632,6 @@ module Pod ...@@ -620,7 +632,6 @@ module Pod
def add_system_framework(name) def add_system_framework(name)
files.new({ files.new({
'lastKnownFileType' => 'wrapper.framework',
'name' => "#{name}.framework", 'name' => "#{name}.framework",
'path' => "System/Library/Frameworks/#{name}.framework", 'path' => "System/Library/Frameworks/#{name}.framework",
'sourceTree' => 'SDKROOT' 'sourceTree' => 'SDKROOT'
......
...@@ -53,6 +53,23 @@ describe "Pod::Xcode::Project" do ...@@ -53,6 +53,23 @@ describe "Pod::Xcode::Project" do
end end
describe "a PBXFileReference" do describe "a PBXFileReference" do
it "sets a default file type" do
framework, library, xcconfig = %w[framework a xcconfig].map { |n| @project.files.new('path' => "Rockin.#{n}") }
framework.lastKnownFileType.should == 'wrapper.framework'
framework.explicitFileType.should == nil
library.lastKnownFileType.should == nil
library.explicitFileType.should == 'archive.ar'
xcconfig.lastKnownFileType.should == 'text.xcconfig'
xcconfig.explicitFileType.should == nil
end
it "doesn't set a file type when overridden" do
fakework = @project.files.new('path' => 'Sup.framework', 'lastKnownFileType' => 'fish')
fakework.lastKnownFileType.should == 'fish'
makework = @project.files.new('path' => 'n2m.framework', 'explicitFileType' => 'tree')
makework.lastKnownFileType.should == nil
end
before do before do
@file = @project.files.new('path' => 'some/file.m') @file = @project.files.new('path' => 'some/file.m')
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