Class: Xcodeproj::Project::Object::PBXFileReference

Inherits:
AbstractGroupEntry show all
Defined in:
lib/xcodeproj/project/object/file_reference.rb

Instance Attribute Summary

Attributes inherited from AbstractPBXObject

#attributes, #project, #uuid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractGroupEntry

#<=>, #destroy

Methods inherited from AbstractPBXObject

#<=>, #==, attribute, create_reflection, #destroy, has_many, has_one, #inspect, isa, #list_by_class, #matches_attributes?, reflection, reflections

Constructor Details

#initializePBXFileReference

Returns a new instance of PBXFileReference.



37
38
39
40
41
42
43
# File 'lib/xcodeproj/project/object/file_reference.rb', line 37

def initialize(*)
  super
  self.path = path if path # sets default name
  self.source_tree ||= 'SOURCE_ROOT'
  self.include_in_index ||= "1"
  set_default_file_type!
end

Class Method Details

.new_static_library(project, product_name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/xcodeproj/project/object/file_reference.rb', line 29

def self.new_static_library(project, product_name)
  new(project, nil,
    "includeInIndex" => "0",
    "sourceTree" => "BUILT_PRODUCTS_DIR",
    "path" => "lib#{product_name}.a"
  )
end

Instance Method Details

#_path=Object



45
# File 'lib/xcodeproj/project/object/file_reference.rb', line 45

alias_method :_path=, :path=

#path=(path) ⇒ Object



46
47
48
49
50
# File 'lib/xcodeproj/project/object/file_reference.rb', line 46

def path=(path)
  self._path = path
  self.name ||= pathname.basename.to_s
  path
end

#pathnameObject



52
53
54
# File 'lib/xcodeproj/project/object/file_reference.rb', line 52

def pathname
  Pathname.new(path)
end

#set_default_file_type!Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/xcodeproj/project/object/file_reference.rb', line 56

def set_default_file_type!
  return if explicit_file_type || last_known_file_type
  case path
  when /\.a$/
    self.explicit_file_type = 'archive.ar'
  when /\.framework$/
    self.last_known_file_type = 'wrapper.framework'
  when /\.xcconfig$/
    self.last_known_file_type = 'text.xcconfig'
  end
end