Module: Xcode::FileReference

Defined in:
lib/xcode/file_reference.rb

Overview

Within the project file the FileReference represents a large number of objects related to files like source files, resources, frameworks, and system libraries.

A FileReference is used as input to add to the various Build Phases.

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#supergroupGroup

This is the group for which this file is contained within.

Returns:

  • (Group)

    the group that contains this file.



16
17
18
# File 'lib/xcode/file_reference.rb', line 16

def supergroup
  @supergroup
end

Class Method Details

.app_product(name) ⇒ Hash

Returns app product properties.

Examples:

app product properties


E21D8AAA14E0F817002E56AA /* newtarget.app */ = {
  isa = PBXFileReference; 
  explicitFileType = wrapper.application; 
  includeInIndex = 0; 
  path = newtarget.app; 
  sourceTree = BUILT_PRODUCTS_DIR; };

Parameters:

  • name (String)

    name of the app product

Returns:

  • (Hash)

    app product properties



116
117
118
119
120
121
122
# File 'lib/xcode/file_reference.rb', line 116

def self.app_product(name)
  { 'isa' => 'PBXFileReference',
    'explicitFileType' => 'wrapper.application',
    'includeInIndex' => 0,
    'path' => "#{name}.app",
    'sourceTree' => "BUILT_PRODUCTS_DIR" }
end

.file(properties) ⇒ Hash

Note:

a ‘name’ and ‘path’ key need to be specified in the framework for the framework to be added correctly.

Generate the properties for a file. A name and a path option need to be specified in the properties.

Parameters:

  • properties (Hash)

    to override or merge with the base properties.

Returns:

  • (Hash)

    properties of a file



28
29
30
31
32
33
34
# File 'lib/xcode/file_reference.rb', line 28

def self.file(properties)
  default_properties = { 'isa' => 'PBXFileReference', 
    'path' => nil,
    'sourceTree' => '<group>' }
  
  default_properties.merge(properties)
end

.framework(properties) ⇒ Hash

Note:

a ‘name’ and ‘path’ key need to be specified in the framework for the framework to be added correctly.

Generate the properties for a framework. A name and a path option need to be specified in the properties

Parameters:

  • properties (Hash)

    to override for the Framework

Returns:

  • (Hash)

    properties for a framework



46
47
48
49
50
51
52
53
54
# File 'lib/xcode/file_reference.rb', line 46

def self.framework(properties)
  default_properties = { 'isa' => "PBXFileReference",
    'lastKnownFileType' => "wrapper.framework",
    'name' => "FRAMEWORK.framework",
    'path' => "FRAMEWORK.framework",
    'sourceTree' => "<group>" }
    
  default_properties.merge(properties)
end

.system_framework(name, properties = {}) ⇒ Hash

Generate the properties for a system framework.

Examples:

CoreGraphics.framework


FileReference.system_framework "CoreGraphics.framework"
FileReference.system_framework "Foundation"

Parameters:

  • name (String)

    of the system framework which can be specified with or without the “.framework” suffix / extension.

  • properties (Hash) (defaults to: {})

    the parameters to override for the system framework

Returns:

  • (Hash)

    system framework properties



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/xcode/file_reference.rb', line 69

def self.system_framework(name,properties = {})
  name = name.gsub(File.extname(name),"")
  
  default_properties = { 'isa' => 'PBXFileReference',
    'lastKnownFileType' => 'wrapper.framework', 
    'name' => "#{name}.framework",
    'path' => "System/Library/Frameworks/#{name}.framework",
    "sourceTree" => "SDKROOT" }
    
  default_properties.merge(properties)
end

.system_library(name, properties = {}) ⇒ Hash

Generate the properties for a system library

Examples:

libz.dylib


FileReference.system_library "libz.dylib"

Parameters:

  • name (String)

    of the system library, which can be found by default in the /usr/lib folder.

  • properties (Types) (defaults to: {})

    the parameters to override for the system library

Returns:

  • (Hash)

    system library properties



93
94
95
96
97
98
99
100
101
# File 'lib/xcode/file_reference.rb', line 93

def self.system_library(name,properties = {})
  default_properties = { 'isa' => 'PBXFileReference',
    'lastKnownFileType' => 'compiled.mach-o.dylib', 
    'name' => name,
    'path' => "usr/lib/#{name}",
    "sourceTree" => "SDKROOT" }
    
  default_properties.merge(properties)
end

Instance Method Details

#remove! {|_self| ... } ⇒ Object

Remove the given file from the project and the supergroup of the file.

Yields:

  • (_self)

Yield Parameters:



127
128
129
130
131
132
133
# File 'lib/xcode/file_reference.rb', line 127

def remove!
  # @todo the removal here does not consider if the files have
  #   been specified within a build phase.
  yield self if block_given?
  supergroup.children.delete identifier if supergroup
  @registry.remove_object identifier
end