Class: Xcake::Target
- Includes:
- Configurable, Visitable
- Defined in:
- lib/xcake/dsl/target.rb,
lib/xcake/dsl/target/sugar.rb,
lib/xcake/dsl/target/configurable.rb
Overview
This class is used to describe a target for a
Xcode project; This forms part of the DSL
and is usually stored in files named Cakefile
.
File patterns collapse
-
#exclude_files ⇒ Array or String
Files to exclude for the target.
Frameworks collapse
-
#linked_targets ⇒ Array<Target>
Targets to link to, use this when you want to use a library or framework target in another target.
-
#schemes ⇒ Array<Scheme>
Schemes for the target.
-
#system_libraries ⇒ Array<String>
System libraries to include for the target.
-
#target_dependencies ⇒ Array<Target>
Targets to use as dependencies.
getters collapse
- #include_files ⇒ Object
-
#system_frameworks ⇒ Array<String>
System frameworks to include for the target Defaults to: - ["Foundation", "UIKit"] for iOS - ["Cocoa"] for OSX.
Instance Attribute Summary collapse
-
#build_phases ⇒ Array<BuildPhase>
The list of build phases for the project.
-
#deployment_target ⇒ String
The minimum deployment version for the target's platform.
-
#language ⇒ String
The language for the target.
-
#name ⇒ String
The name of the target.
-
#pinned_build_phases ⇒ Array<BuildPhase>
The list of build phases to place first for the project.
-
#platform ⇒ String
The platform for the target.
-
#type ⇒ String
The type of the target.
Attributes included from Configurable
Frameworks collapse
-
#initialize {|_self| ... } ⇒ Target
constructor
A new instance of Target.
Working with a target collapse
-
#scheme(name, &block) ⇒ Scheme
Creates a new scheme for the target.
Conversion collapse
Instance Method Summary collapse
-
#copy_files_build_phase(name, &block) ⇒ CopyFilesBuildPhase
Creates a new Copy Files build phase for the target.
- #default_debug_settings ⇒ Object
- #default_release_settings ⇒ Object
- #default_settings ⇒ Object
-
#headers_build_phase(&block) ⇒ HeadersBuildPhase
Creates a new Copy Headers build phase for the target.
- #parent_configurable ⇒ Object
-
#pre_shell_script_build_phase(name, script, &block) ⇒ ShellScriptBuildPhase
Creates a new Shell Script build phase for the target before all of the other build phases.
-
#shell_script_build_phase(name, script, &block) ⇒ ShellScriptBuildPhase
Creates a new Shell Script build phase for the target.
Methods included from Visitable
Methods included from Configurable
#all_configurations, #all_configurations=, #configuration, #configurations_of_type, #copy_parent_configurations, #debug_configuration, #default_settings_for_type, #release_configuration
Constructor Details
#initialize {|_self| ... } ⇒ Target
Returns a new instance of Target.
189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/xcake/dsl/target.rb', line 189 def initialize @pinned_build_phases = [] @build_phases = [] @exclude_files = [] @linked_targets = [] @system_libraries = [] @target_dependencies = [] @schemes = [] yield(self) if block_given? end |
Instance Attribute Details
#build_phases ⇒ Array<BuildPhase>
Returns the list of build phases for the project.
43 44 45 |
# File 'lib/xcake/dsl/target.rb', line 43 def build_phases @build_phases end |
#deployment_target ⇒ String
Returns the minimum deployment version for the target's platform.
28 29 30 |
# File 'lib/xcake/dsl/target.rb', line 28 def deployment_target @deployment_target end |
#exclude_files ⇒ Array or String
Returns files to exclude for the target. Supports regular expressions.
143 144 145 |
# File 'lib/xcake/dsl/target.rb', line 143 def exclude_files @exclude_files end |
#include_files ⇒ Object
134 135 136 |
# File 'lib/xcake/dsl/target.rb', line 134 def include_files @include_files end |
#language ⇒ String
Returns the language for the target.
Can be :objc
, :swift
.
33 34 35 |
# File 'lib/xcake/dsl/target.rb', line 33 def language @language end |
#linked_targets ⇒ Array<Target>
Returns targets to link to, use this when you want to use a library or framework target in another target.
174 175 176 |
# File 'lib/xcake/dsl/target.rb', line 174 def linked_targets @linked_targets end |
#name ⇒ String
Returns the name of the target.
12 13 14 |
# File 'lib/xcake/dsl/target.rb', line 12 def name @name end |
#pinned_build_phases ⇒ Array<BuildPhase>
Returns the list of build phases to place first for the project.
38 39 40 |
# File 'lib/xcake/dsl/target.rb', line 38 def pinned_build_phases @pinned_build_phases end |
#platform ⇒ String
Returns the platform for the target.
Can be :ios
, :osx
, :tvos
, :watchos
.
23 24 25 |
# File 'lib/xcake/dsl/target.rb', line 23 def platform @platform end |
#schemes ⇒ Array<Scheme>
Returns schemes for the target.
178 179 180 |
# File 'lib/xcake/dsl/target.rb', line 178 def schemes @schemes end |
#system_frameworks ⇒ Array<String>
Returns system frameworks to include for the target Defaults to:
- ["Foundation", "UIKit"] for iOS
- ["Cocoa"] for OSX.
156 157 158 |
# File 'lib/xcake/dsl/target.rb', line 156 def system_frameworks @system_frameworks end |
#system_libraries ⇒ Array<String>
Returns system libraries to include for the target.
164 165 166 |
# File 'lib/xcake/dsl/target.rb', line 164 def system_libraries @system_libraries end |
#target_dependencies ⇒ Array<Target>
Returns targets to use as dependencies.
168 169 170 |
# File 'lib/xcake/dsl/target.rb', line 168 def target_dependencies @target_dependencies end |
#type ⇒ String
Returns the type of the target.
Can be :application
, :dynamic_library
,
framework
or :static_library
.
18 19 20 |
# File 'lib/xcake/dsl/target.rb', line 18 def type @type end |
Instance Method Details
#copy_files_build_phase(name, &block) ⇒ CopyFilesBuildPhase
Creates a new Copy Files build phase for the target
16 17 18 19 20 21 |
# File 'lib/xcake/dsl/target/sugar.rb', line 16 def copy_files_build_phase(name, &block) phase = CopyFilesBuildPhase.new(&block) phase.name = name build_phases << phase phase end |
#default_debug_settings ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xcake/dsl/target/configurable.rb', line 13 def default_debug_settings Xcake::Constants .common_build_settings(:debug, platform, deployment_target.to_s, type, language) .merge!(default_settings) .merge('SWIFT_OPTIMIZATION_LEVEL' => '-Onone') end |
#default_release_settings ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/xcake/dsl/target/configurable.rb', line 24 def default_release_settings Xcake::Constants .common_build_settings(:release, platform, deployment_target.to_s, type, language) .merge!(default_settings) end |
#default_settings ⇒ Object
7 8 9 10 11 |
# File 'lib/xcake/dsl/target/configurable.rb', line 7 def default_settings { 'INFOPLIST_FILE' => "#{name}/Supporting Files/Info.plist" } end |
#headers_build_phase(&block) ⇒ HeadersBuildPhase
Creates a new Copy Headers build phase for the target
31 32 33 34 35 |
# File 'lib/xcake/dsl/target/sugar.rb', line 31 def headers_build_phase(&block) phase = HeadersBuildPhase.new(&block) build_phases << phase phase end |
#parent_configurable ⇒ Object
3 4 5 |
# File 'lib/xcake/dsl/target/configurable.rb', line 3 def parent_configurable @project end |
#pre_shell_script_build_phase(name, script, &block) ⇒ ShellScriptBuildPhase
Creates a new Shell Script build phase for the target before all of the other build phases
48 49 50 51 52 53 54 |
# File 'lib/xcake/dsl/target/sugar.rb', line 48 def pre_shell_script_build_phase(name, script, &block) phase = ShellScriptBuildPhase.new(&block) phase.name = name phase.script = script pinned_build_phases << phase phase end |
#scheme(name, &block) ⇒ Scheme
Creates a new scheme for the target
211 212 213 214 215 |
# File 'lib/xcake/dsl/target.rb', line 211 def scheme(name, &block) scheme = Scheme.new(name, &block) schemes << scheme scheme end |
#shell_script_build_phase(name, script, &block) ⇒ ShellScriptBuildPhase
Creates a new Shell Script build phase for the target
67 68 69 70 71 72 73 |
# File 'lib/xcake/dsl/target/sugar.rb', line 67 def shell_script_build_phase(name, script, &block) phase = ShellScriptBuildPhase.new(&block) phase.name = name phase.script = script build_phases << phase phase end |
#to_s ⇒ Object
231 232 233 |
# File 'lib/xcake/dsl/target.rb', line 231 def to_s "Target<#{name}>" end |