Module: Xcode::BuildPhase

Defined in:
lib/xcode/build_phase.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.copy_headersBuildPhase



65
66
67
68
69
70
# File 'lib/xcode/build_phase.rb', line 65

def self.copy_headers
  { 'isa' => 'PBXHeadersBuildPhase',
    'buildActionMask' => '2147483647',
    'files' => [],
    'runOnlyForDeploymentPostprocessing' => '0' }
end

.frameworkBuildPhase

Returns properties for a link frameworks build phase.

Examples:


7165D44D146B4EA100DE2F0E /* Frameworks */ = {
  isa = PBXFrameworksBuildPhase;                                        
  buildActionMask = 2147483647;                                         
  files = (                                                             
    7165D455146B4EA100DE2F0E /* UIKit.framework in Frameworks */,       
    7165D457146B4EA100DE2F0E /* Foundation.framework in Frameworks */,  
    7165D459146B4EA100DE2F0E /* CoreGraphics.framework in Frameworks */,
  );                                                                    
  runOnlyForDeploymentPostprocessing = 0;                               
};                                                                      


21
22
23
24
25
26
# File 'lib/xcode/build_phase.rb', line 21

def self.framework
  { 'isa' => 'PBXFrameworksBuildPhase',
    'buildActionMask' => '2147483647',
    'files' => [],
    'runOnlyForDeploymentPostprocessing' => '0' }
end

.resourcesBuildPhase



41
42
43
44
45
46
# File 'lib/xcode/build_phase.rb', line 41

def self.resources
  { 'isa' => 'PBXResourcesBuildPhase',
    'buildActionMask' => '2147483647',
    'files' => [],
    'runOnlyForDeploymentPostprocessing' => '0' }
end

.run_scriptBuildPhase



51
52
53
54
55
56
57
58
59
60
# File 'lib/xcode/build_phase.rb', line 51

def self.run_script
  { 'isa' => 'PBXShellScriptBuildPhase',
    'buildActionMask' => '2147483647',
    'files' => [],
    'inputPaths' => [],
    'outputPaths' => [],
    'shellPath' => '/bin/sh',
    'shellScript' => '',
    'runOnlyForDeploymentPostprocessing' => '0' }
end

.sourcesBuildPhase



31
32
33
34
35
36
# File 'lib/xcode/build_phase.rb', line 31

def self.sources
  { 'isa' => 'PBXSourcesBuildPhase',
    'buildActionMask' => '2147483647',
    'files' => [],
    'runOnlyForDeploymentPostprocessing' => '0' }
end

Instance Method Details

#add_build_file(file, settings = {}) ⇒ Object

Add the specified file to the Build Phase.

First a BuildFile entry is created for the file and then the build file entry is added to the particular build phase. A BuildFile identifier must exist for each target.

phase.

Examples:

adding a source file to the sources build phase


spec_file = project.group('Specs/Controller').create_file('FirstControllerSpec.m')
project.target('Specs').sources_build_phase.add_build_file spec_file

adding a source file, that does not use ARC, to the sources build phase


spec_file = project.group('Specs/Controller').create_file('FirstControllerSpec.m')
project.target('Specs').sources_build_phase.add_build_file spec_file, { 'COMPILER_FLAGS' => "-fno-objc-arc" }


134
135
136
137
138
139
140
# File 'lib/xcode/build_phase.rb', line 134

def add_build_file(file,settings = {})
  find_file_by = file.path || file.name
  unless build_file(find_file_by)
    new_build_file = @registry.add_object BuildFile.buildfile(file.identifier,settings)
    @properties['files'] << new_build_file.identifier
  end
end

#add_build_file_with_private_privacy(file) ⇒ Object

Add the specific file to the Build Phase with the privacy settings used for header files that are added to the build headers phase.

Examples:

Add a source header file as private


spec_file = project.group('Specs/Controller').create_file('FirstControllerSpec.h')
project.target('Specs').headers_build_phase.add_build_file_with_private_privacy


181
182
183
# File 'lib/xcode/build_phase.rb', line 181

def add_build_file_with_private_privacy(file)
  add_build_file file, { "ATTRIBUTES" => [ 'Private' ] }
end

#add_build_file_with_public_privacy(file) ⇒ Object

Add the specific file to the Build Phase with the privacy settings used for header files that are added to the build headers phase.

Examples:

Add a source header file as public


spec_file = project.group('Specs/Controller').create_file('FirstControllerSpec.h')
project.target('Specs').headers_build_phase.add_build_file_with_public_privacy


165
166
167
# File 'lib/xcode/build_phase.rb', line 165

def add_build_file_with_public_privacy(file)
  add_build_file file, { "ATTRIBUTES" => [ 'Public' ] }
end

#add_build_file_without_arc(file) ⇒ Object

Add the specified file to the Build Phase that will have specific compiler flags to disable ARC.



149
150
151
# File 'lib/xcode/build_phase.rb', line 149

def add_build_file_without_arc(file)
  add_build_file file, { 'COMPILER_FLAGS' => "-fno-objc-arc" }
end

#build_file(name) ⇒ FileReference

Note:

this is the FileReference, the file being built and not the instance of the BuildFile.

Find the first file that has the name or path that matches the specified parameter.

See Also:



108
109
110
# File 'lib/xcode/build_phase.rb', line 108

def build_file(name)
  build_files.find {|file| file.name == name or file.path == name }
end

#build_filesArray<FileReference>

Return the files that are referenced by the build files. This traverses the level of indirection to make it easier to get to the FileReference.

Another method, file, exists which will return the BuildFile references.



91
92
93
# File 'lib/xcode/build_phase.rb', line 91

def build_files
  files.map {|file| file.file_ref }
end

#file(name) ⇒ BuildFile

Return the BuildFile given the file name.



79
80
81
# File 'lib/xcode/build_phase.rb', line 79

def file(name)
  files.find {|file| file.file_ref.name == name or file.file_ref.path == name  }
end