Module: Xcode::Target
- Defined in:
- lib/xcode/target.rb
Overview
Within a project a user may define a number of targets. These targets may be to generate the application, generate a universal framework, or execute tests.
Creating a target is usually done within a Project. There a specific target type can be specified.
Instance Attribute Summary collapse
-
#project ⇒ Project
The reference to the project for which these targets reside.
Class Method Summary collapse
-
.aggregate ⇒ Hash
This is a generic properties hash for an aggregate target.
-
.bundle ⇒ Hash
This is a generic properties hash for an a bundle target.
-
.native ⇒ Hash
This is a generic properties hash for a native target.
Instance Method Summary collapse
- #add_dependency(target) ⇒ Object
- #build_phase(type, &block) ⇒ Object
-
#copy_headers_build_phase(&block) ⇒ BuildPhase
The copy headers specific build phase of the target.
-
#create_build_phase(phase_name) {|build_phase| ... } ⇒ BuildPhase
Create a build phase with the given name.
-
#create_build_phases(*base_phase_names) ⇒ Array
Create multiple build phases at the same time.
-
#create_product_reference(name) ⇒ Resource
Create a product reference file and add it to the product.
-
#framework_build_phase(&block) ⇒ BuildPhase
The framework specific build phase of the target.
-
#resources_build_phase(&block) ⇒ BuildPhase
The resources specific build phase of the target.
-
#run_script_build_phase(&block) ⇒ BuildPhase
The run script specific build phase of the target.
-
#sources_build_phase(&block) ⇒ BuildPhase
The sources specific build phase of the target.
Instance Attribute Details
#project ⇒ Project
Returns the reference to the project for which these targets reside.
96 97 98 |
# File 'lib/xcode/target.rb', line 96 def project @project end |
Class Method Details
.aggregate ⇒ Hash
This is a generic properties hash for an aggregate target.
86 87 88 89 90 91 92 93 |
# File 'lib/xcode/target.rb', line 86 def self.aggregate { 'isa' => 'PBXAggregateTarget', 'buildConfigurationList' => nil, 'buildPhases' => [], 'dependencies' => [], 'name' => '', 'productName' => '' } end |
.bundle ⇒ Hash
This is a generic properties hash for an a bundle target. It shares numerous similarities with the native target, it simply has a bundle product type.
60 61 62 |
# File 'lib/xcode/target.rb', line 60 def self.bundle self.native.merge('productType' => 'com.apple.product-type.bundle') end |
.native ⇒ Hash
This is a generic properties hash for a native target
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/xcode/target.rb', line 42 def self.native { 'isa' => 'PBXNativeTarget', 'buildConfigurationList' => nil, 'buildPhases' => [], 'buildRules' => [], 'dependencies' => [], 'name' => '', 'productName' => '', 'productReference' => '', 'productType' => 'com.apple.product-type.application' } end |
Instance Method Details
#add_dependency(target) ⇒ Object
200 201 202 203 204 205 206 207 208 |
# File 'lib/xcode/target.rb', line 200 def add_dependency(target) target_dependency = TargetDependency.default target_dependency = @registry.add_object target_dependency target_dependency.create_dependency_on target target_dependency end |
#build_phase(type, &block) ⇒ Object
133 134 135 136 137 |
# File 'lib/xcode/target.rb', line 133 def build_phase(type,&block) found_build_phase = build_phases.find {|phase| phase.isa == type } found_build_phase.instance_eval(&block) if block_given? found_build_phase end |
#copy_headers_build_phase(&block) ⇒ BuildPhase
Returns the copy headers specific build phase of the target.
129 130 131 |
# File 'lib/xcode/target.rb', line 129 def copy_headers_build_phase(&block) build_phase 'PBXHeadersBuildPhase', &block end |
#create_build_phase(phase_name) {|build_phase| ... } ⇒ BuildPhase
Create a build phase with the given name. Available build phases:
-
sources
-
resources
-
framework
-
run_script
-
copy_headers
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/xcode/target.rb', line 160 def create_build_phase(phase_name) # Register a BuildPhase with the default properties specified by the name. build_phase = @registry.add_object(BuildPhase.send("#{phase_name}")) # Add the build phase to the list of build phases for this target. # @todo this is being done commonly in the application in multiple places # and it bugs me. Perhaps some special module could be mixed into the # Array of results that are returned. @properties['buildPhases'] << build_phase.identifier yield build_phase if block_given? build_phase.save! end |
#create_build_phases(*base_phase_names) ⇒ Array
Create multiple build phases at the same time.
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/xcode/target.rb', line 184 def create_build_phases *base_phase_names base_phase_names.compact.flatten.map do |phase_name| build_phase = create_build_phase phase_name do |build_phase| yield build_phase if block_given? end build_phase.save! end end |
#create_product_reference(name) ⇒ Resource
Create a product reference file and add it to the product. This is by default added to the ‘Products’ group.
217 218 219 220 221 |
# File 'lib/xcode/target.rb', line 217 def create_product_reference(name) product = project.products_group.create_product_reference(name) product_reference = product.identifier product end |
#framework_build_phase(&block) ⇒ BuildPhase
Returns the framework specific build phase of the target.
101 102 103 |
# File 'lib/xcode/target.rb', line 101 def framework_build_phase(&block) build_phase 'PBXFrameworksBuildPhase', &block end |
#resources_build_phase(&block) ⇒ BuildPhase
Returns the resources specific build phase of the target.
115 116 117 |
# File 'lib/xcode/target.rb', line 115 def resources_build_phase(&block) build_phase 'PBXResourcesBuildPhase', &block end |
#run_script_build_phase(&block) ⇒ BuildPhase
Returns the run script specific build phase of the target.
122 123 124 |
# File 'lib/xcode/target.rb', line 122 def run_script_build_phase(&block) build_phase 'PBXShellScriptBuildPhase', &block end |
#sources_build_phase(&block) ⇒ BuildPhase
Returns the sources specific build phase of the target.
108 109 110 |
# File 'lib/xcode/target.rb', line 108 def sources_build_phase(&block) build_phase 'PBXSourcesBuildPhase', &block end |