Class: Xcodeproj::Project::Object::PBXFileReference
- Inherits:
-
AbstractObject
- Object
- AbstractObject
- Xcodeproj::Project::Object::PBXFileReference
- Defined in:
- lib/xcodeproj/project/object/file_reference.rb
Overview
This class represents a reference to a file in the file system.
Attributes collapse
-
#comments ⇒ String
Comments associated with this file.
-
#explicit_file_type ⇒ String
The file type (apparently) used for products generated by Xcode (i.e. applications, libraries).
-
#fileEncoding ⇒ String
A string containing a number which represents the encoding format of the file.
-
#include_in_index ⇒ String
Whether this file should be indexed.
-
#indent_width ⇒ String
The width of the indent.
-
#last_known_file_type ⇒ String
The file type guessed by Xcode.
-
#line_ending ⇒ String
Apparently whether Xcode should add, if needed, a new line feed before saving the file.
-
#name ⇒ String
The name of the reference, often not present.
-
#path ⇒ String
The path to the file relative to the source tree.
-
#plist_structure_definition_identifier ⇒ String
A string that specifies the UTI for the structure of a plist file.
-
#source_tree ⇒ String
The directory to which the path is relative.
-
#tab_width ⇒ String
The width of the tabs.
-
#uses_tabs ⇒ String
Whether Xcode should use tabs for text alignment.
-
#wraps_lines ⇒ String
Whether Xcode should wrap lines.
-
#xc_language_specification_identifier ⇒ String
A string that specifies the UTI for the syntax highlighting.
Attributes inherited from AbstractObject
Helpers collapse
-
#build_files ⇒ Array<PBXBuildFile>
The build files associated with the current file reference.
-
#display_name ⇒ String
The name of the file taking into account the path if needed.
-
#file_reference_proxies ⇒ Array<PBXReferenceProxy>
If this file reference represents an external Xcode project reference then this will return proxies for file references contained in the external Xcode project.
-
#hierarchy_path ⇒ String
A representation of the reference hierarchy.
-
#move(new_parent) ⇒ void
Moves the reference to a new parent.
-
#parent ⇒ PBXGroup, PBXProject
The parent of the file.
-
#parents ⇒ Array<PBXGroup, PBXProject>
The list of the parents of the reference.
-
#project_reference_metadata ⇒ ObjectDictionary?
If this file reference represents an external Xcode project reference then this will return metadata about it which includes the reference to the ‘Products’ group that’s created in this project (the project that includes the external project).
-
#proxy? ⇒ Bool
Checks whether the reference is a proxy.
-
#proxy_containers ⇒ Array<PBXContainerItemProxy>
If this file reference represents an external Xcode project reference then this will return the objects that are ‘containers’ for items contained in the external Xcode project.
-
#real_path ⇒ Pathname
source tree.
-
#remove_from_project ⇒ void
In addition to removing the file reference, this will also remove any items related to this reference in case it represents an external Xcode project.
-
#set_explicit_file_type(type = nil) ⇒ void
Sets the explicit file type according to the extension of the path, and clears the last known file type.
-
#set_last_known_file_type(type = nil) ⇒ void
Sets the last known file type according to the extension of the path.
-
#set_path(path) ⇒ void
Allows to set the path according to the source tree of the reference.
-
#set_source_tree(source_tree) ⇒ void
Sets the source tree of the reference.
-
#target_dependency_proxies ⇒ Array<PBXTargetDependency>
If this file reference represents an external Xcode project reference then this will return dependencies on targets contained in the external Xcode project.
Methods inherited from AbstractObject
#<=>, #==, #inspect, isa, #pretty_print, #sort, #sort_recursively, #to_hash
Instance Attribute Details
#comments ⇒ String
This is apparently no longer used by Xcode.
Returns Comments associated with this file.
114 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 114 attribute :comments, String |
#explicit_file_type ⇒ String
Returns the file type (apparently) used for products generated by Xcode (i.e. applications, libraries).
36 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 36 attribute :explicit_file_type, String |
#fileEncoding ⇒ String
Returns a string containing a number which represents the encoding format of the file.
56 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 56 attribute :fileEncoding, String |
#include_in_index ⇒ String
Apparently present only for products generated by Xcode with a value of ‘0`.
Returns whether this file should be indexed. It can be either ‘0` or `1`.
51 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 51 attribute :include_in_index, String, '1' |
#indent_width ⇒ String
Returns The width of the indent.
86 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 86 attribute :indent_width, String |
#last_known_file_type ⇒ String
This attribute is not present if there is an ‘explicit_file_type`.
Returns the file type guessed by Xcode.
43 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 43 attribute :last_known_file_type, String |
#line_ending ⇒ String
Returns Apparently whether Xcode should add, if needed, a new line feed before saving the file.
108 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 108 attribute :line_ending, String |
#name ⇒ String
Returns the name of the reference, often not present.
13 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 13 attribute :name, String |
#path ⇒ String
Returns the path to the file relative to the source tree.
17 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 17 attribute :path, String |
#plist_structure_definition_identifier ⇒ String
Returns a string that specifies the UTI for the structure of a plist file.
72 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 72 attribute :plist_structure_definition_identifier, String |
#source_tree ⇒ String
The accepted values are:
-
‘<absolute>` for absolute paths
-
‘<group>` for paths relative to the group
-
‘SOURCE_ROOT` for paths relative to the project
-
‘DEVELOPER_DIR` for paths relative to the developer directory.
-
‘BUILT_PRODUCTS_DIR` for paths relative to the build products directory.
-
‘SDKROOT` for paths relative to the SDK directory.
Returns the directory to which the path is relative.
31 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 31 attribute :source_tree, String, 'SOURCE_ROOT' |
#tab_width ⇒ String
Returns The width of the tabs.
93 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 93 attribute :tab_width, String |
#uses_tabs ⇒ String
Returns Whether Xcode should use tabs for text alignment.
79 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 79 attribute :uses_tabs, String |
#wraps_lines ⇒ String
Returns Whether Xcode should wrap lines.
100 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 100 attribute :wraps_lines, String |
#xc_language_specification_identifier ⇒ String
Returns a string that specifies the UTI for the syntax highlighting.
64 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 64 attribute :xc_language_specification_identifier, String |
Instance Method Details
#build_files ⇒ Array<PBXBuildFile>
Returns the build files associated with the current file reference.
194 195 196 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 194 def build_files referrers.grep(PBXBuildFile) end |
#display_name ⇒ String
Returns the name of the file taking into account the path if needed.
125 126 127 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 125 def display_name name || (File.basename(path) if path) end |
#file_reference_proxies ⇒ Array<PBXReferenceProxy>
If this file reference represents an external Xcode project reference then this will return proxies for file references contained in the external Xcode project.
271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 271 def file_reference_proxies containers = proxy_containers if containers.empty? [] else project.objects.select do |object| object.isa == 'PBXReferenceProxy' && containers.include?(object.remote_ref) end end end |
#hierarchy_path ⇒ String
Returns A representation of the reference hierarchy.
144 145 146 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 144 def hierarchy_path GroupableHelper.hierarchy_path(self) end |
#move(new_parent) ⇒ void
This method returns an undefined value.
Moves the reference to a new parent.
155 156 157 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 155 def move(new_parent) GroupableHelper.move(self, new_parent) end |
#parent ⇒ PBXGroup, PBXProject
Returns the parent of the file.
131 132 133 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 131 def parent GroupableHelper.parent(self) end |
#parents ⇒ Array<PBXGroup, PBXProject>
Returns The list of the parents of the reference.
138 139 140 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 138 def parents GroupableHelper.parents(self) end |
#project_reference_metadata ⇒ ObjectDictionary?
If this file reference represents an external Xcode project reference then this will return metadata about it which includes the reference to the ‘Products’ group that’s created in this project (the project that includes the external project).
244 245 246 247 248 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 244 def project.root_object.project_references.find do |project_reference| project_reference[:project_ref] == self end end |
#proxy? ⇒ Bool
Checks whether the reference is a proxy.
232 233 234 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 232 def proxy? false end |
#proxy_containers ⇒ Array<PBXContainerItemProxy>
If this file reference represents an external Xcode project reference then this will return the objects that are ‘containers’ for items contained in the external Xcode project.
257 258 259 260 261 262 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 257 def proxy_containers project.objects.select do |object| object.isa == 'PBXContainerItemProxy' && object.container_portal == uuid end end |
#real_path ⇒ Pathname
source tree.
162 163 164 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 162 def real_path GroupableHelper.real_path(self) end |
#remove_from_project ⇒ void
This method returns an undefined value.
In addition to removing the file reference, this will also remove any items related to this reference in case it represents an external Xcode project.
310 311 312 313 314 315 316 317 318 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 310 def remove_from_project if project_reference = file_reference_proxies.each(&:remove_from_project) target_dependency_proxies.each(&:remove_from_project) project_reference[:product_group].remove_from_project project.root_object.project_references.delete(project_reference) end super end |
#set_explicit_file_type(type = nil) ⇒ void
This method returns an undefined value.
Sets the explicit file type according to the extension of the path, and clears the last known file type.
216 217 218 219 220 221 222 223 224 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 216 def set_explicit_file_type(type = nil) self.last_known_file_type = nil if type self.explicit_file_type = type elsif path extension = Pathname(path).extname[1..-1] self.explicit_file_type = Constants::FILE_TYPES_BY_EXTENSION[extension] end end |
#set_last_known_file_type(type = nil) ⇒ void
This method returns an undefined value.
Sets the last known file type according to the extension of the path.
202 203 204 205 206 207 208 209 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 202 def set_last_known_file_type(type = nil) if type self.last_known_file_type = type elsif path extension = Pathname(path).extname[1..-1] self.last_known_file_type = Constants::FILE_TYPES_BY_EXTENSION[extension] end end |
#set_path(path) ⇒ void
This method returns an undefined value.
Allows to set the path according to the source tree of the reference.
183 184 185 186 187 188 189 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 183 def set_path(path) if path GroupableHelper.set_path_with_source_tree(self, path, source_tree) else self.path = nil end end |
#set_source_tree(source_tree) ⇒ void
This method returns an undefined value.
Sets the source tree of the reference.
173 174 175 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 173 def set_source_tree(source_tree) GroupableHelper.set_source_tree(self, source_tree) end |
#target_dependency_proxies ⇒ Array<PBXTargetDependency>
If this file reference represents an external Xcode project reference then this will return dependencies on targets contained in the external Xcode project.
290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/xcodeproj/project/object/file_reference.rb', line 290 def target_dependency_proxies containers = proxy_containers if containers.empty? [] else project.objects.select do |object| object.isa == 'PBXTargetDependency' && containers.include?(object.target_proxy) end end end |