Class: Xcake::Target
- Inherits:
-
Object
- Object
- 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
Instance Attribute Summary collapse
-
#build_phases ⇒ Array<BuildPhase>
The list of build phases for the project.
-
#build_rules ⇒ Array<BuildRule>
The list of build rules 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(project) {|_self| ... } ⇒ Target
constructor
A new instance of Target.
Working with a target collapse
-
#scheme(name, &block) ⇒ Scheme
Creates a new scheme for the target.
getters collapse
Conversion collapse
Instance Method Summary collapse
-
#build_rule(name, file_type, output_files, output_files_compiler_flags, script, &block) ⇒ BuildRule
Creates a new build rule for the target.
-
#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(project) {|_self| ... } ⇒ Target
Returns a new instance of Target.
197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/xcake/dsl/target.rb', line 197 def initialize(project) @pinned_build_phases = [] @build_phases = [] @build_rules = [] @exclude_files = [] @linked_targets = [] @system_libraries = [] @target_dependencies = [] @schemes = [] @project = project 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 |
#build_rules ⇒ Array<BuildRule>
Returns the list of build rules for the project.
48 49 50 |
# File 'lib/xcake/dsl/target.rb', line 48 def build_rules @build_rules 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.
148 149 150 |
# File 'lib/xcake/dsl/target.rb', line 148 def exclude_files @exclude_files end |
#include_files ⇒ Object
229 230 231 232 |
# File 'lib/xcake/dsl/target.rb', line 229 def include_files # Import files in folder with same name as target by default @include_files ||= ["./#{@name}/**/*.*"] 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.
179 180 181 |
# File 'lib/xcake/dsl/target.rb', line 179 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.
183 184 185 |
# File 'lib/xcake/dsl/target.rb', line 183 def schemes @schemes end |
#system_frameworks ⇒ Object
234 235 236 237 |
# File 'lib/xcake/dsl/target.rb', line 234 def system_frameworks # Use default frameworks by default @system_frameworks ||= default_system_frameworks_for(platform) end |
#system_libraries ⇒ Array<String>
Returns system libraries to include for the target.
169 170 171 |
# File 'lib/xcake/dsl/target.rb', line 169 def system_libraries @system_libraries end |
#target_dependencies ⇒ Array<Target>
Returns targets to use as dependencies.
173 174 175 |
# File 'lib/xcake/dsl/target.rb', line 173 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
#build_rule(name, file_type, output_files, output_files_compiler_flags, script, &block) ⇒ BuildRule
Creates a new build rule for the target
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/xcake/dsl/target/sugar.rb', line 86 def build_rule(name, file_type, output_files, output_files_compiler_flags, script, &block) rule = BuildRule.new(&block) rule.name = name rule.file_type = file_type rule.output_files = output_files rule.output_files_compiler_flags = output_files_compiler_flags rule.script = script build_rules << rule rule end |
#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 |
#info_plist_paths ⇒ Object
239 240 241 |
# File 'lib/xcake/dsl/target.rb', line 239 def info_plist_paths all_configurations.map { |config| config.settings['INFOPLIST_FILE'] }.uniq 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
221 222 223 224 225 |
# File 'lib/xcake/dsl/target.rb', line 221 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
245 246 247 |
# File 'lib/xcake/dsl/target.rb', line 245 def to_s "Target<#{name}>" end |