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

PBXFileReference sets some file types

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