Class: ZergXcode::Objects::PBXBuildFile

Inherits:
XcodeObject show all
Defined in:
lib/zerg_xcode/objects/pbx_build_file.rb

Overview

A file used for building. Points to a PBXFileRef.

Instance Attribute Summary

Attributes inherited from XcodeObject

#archive_id, #version

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from XcodeObject

#[], #[]=, #_attr_hash, #attrs, #copy_metadata, from, #initialize, #isa, new, #shallow_copy, #visit, #visit_array, #visit_hash, #visit_once, #visit_value, #xref_key

Constructor Details

This class inherits a constructor from ZergXcode::XcodeObject

Class Method Details

.for(file_ref) ⇒ Object

Creates a build file for the given file reference.



29
30
31
# File 'lib/zerg_xcode/objects/pbx_build_file.rb', line 29

def self.for(file_ref)
  self.new 'fileRef' => file_ref
end

Instance Method Details

#file_typeObject

The type of the referenced file.



9
10
11
# File 'lib/zerg_xcode/objects/pbx_build_file.rb', line 9

def file_type
  self['fileRef']['explicitFileType'] || self['fileRef']['lastKnownFileType']
end

#filenameObject

The name of the referenced file.



4
5
6
# File 'lib/zerg_xcode/objects/pbx_build_file.rb', line 4

def filename
  self['fileRef']['path']
end

#guessed_build_phase_typeObject

Guesses the type of the build phase that this file should belong to. This can be useful when figuring out which build phase to add a file to.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/zerg_xcode/objects/pbx_build_file.rb', line 15

def guessed_build_phase_type
  case file_type
  when /\.h$/
    return 'PBXHeadersBuildPhase'
  when /^sourcecode/
    return 'PBXSourcesBuildPhase'
  when /\.framework$/, /\.ar$/
    return 'PBXFrameworksBuildPhase'
  else
    return 'PBXResourcesBuildPhase'
  end
end

#xref_nameObject

:nodoc: override xref_name to borrow the referenced object’s name



34
35
36
# File 'lib/zerg_xcode/objects/pbx_build_file.rb', line 34

def xref_name
  self['fileRef'].xref_name
end