Class: Xcake::Project
- Inherits:
-
Object
- Object
- Xcake::Project
- Includes:
- Hooks, Hooks::InstanceHooks, Configurable, Visitable
- Defined in:
- lib/xcake/dsl/project.rb,
lib/xcake/dsl/project/hooks.rb,
lib/xcake/dsl/project/sugar.rb
Overview
This class is used to describe the overall
Xcode project structure; This forms part of the DSL
and is usally stored in files named Cakefile
.
The Project creates a hiearchy of targets and configurations necessary to generate a xcode project.
Configuring a project collapse
-
#class_prefix ⇒ String
The prefix used for Objective-C Classes.
-
#name ⇒ String
The name of the project file.
-
#organization ⇒ String
The name of your organization.
-
#targets ⇒ Array<Target>
The list of targets for the project.
Attributes included from Configurable
Creating a project collapse
-
#initialize(name = 'Project') {|_self| ... } ⇒ Project
constructor
A new instance of Project.
Working with a project collapse
-
#target(&block) ⇒ Target
Defines a new target.
Conversion collapse
Visitable collapse
Instance Method Summary collapse
-
#application_for(platform, deployment_target, language = :objc) ⇒ Target
Defines a new application target.
- #configure_test_target_for_host_target(test_target, host_target) ⇒ Object private
-
#extension_for(host_target) {|target| ... } ⇒ Target
Defines a extension target.
-
#project {|_self| ... } ⇒ Object
Passes the project instance to a block.
-
#ui_tests_for(host_target) ⇒ Target
Defines a new ui test target.
-
#unit_tests_for(host_target) ⇒ Target
Defines a new unit test target.
-
#watch_app_for(host_target, deployment_target, language = :objc) {|watch_app_target, watch_extension_target| ... } ⇒ Object
Defines targets for watch app.
Methods included from Configurable
#all_configurations, #all_configurations=, #configuration, #configurations_of_type, #copy_parent_configurations, #debug_configuration, #default_settings_for_type, #parent_configurable, #release_configuration
Constructor Details
#initialize(name = 'Project') {|_self| ... } ⇒ Project
Returns a new instance of Project.
48 49 50 51 52 53 |
# File 'lib/xcake/dsl/project.rb', line 48 def initialize(name = 'Project') @name = name @targets = [] yield(self) if block_given? end |
Instance Attribute Details
#class_prefix ⇒ String
Returns the prefix used for Objective-C Classes. This is used by xcode when creating new files.
23 24 25 |
# File 'lib/xcake/dsl/project.rb', line 23 def class_prefix @class_prefix end |
#name ⇒ String
Returns the name of the project file. This is used as the filename.
19 20 21 |
# File 'lib/xcake/dsl/project.rb', line 19 def name @name end |
#organization ⇒ String
Returns the name of your organization. This is used by xcode when creating new files.
28 29 30 |
# File 'lib/xcake/dsl/project.rb', line 28 def organization @organization end |
#targets ⇒ Array<Target>
Returns the list of targets for the project.
32 33 34 |
# File 'lib/xcake/dsl/project.rb', line 32 def targets @targets end |
Instance Method Details
#accept(visitor) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/xcake/dsl/project.rb', line 79 def accept(visitor) visitor.visit(self) targets.each do |t| visitor.visit(t) visitor.leave(t) end visitor.leave(self) end |
#application_for(platform, deployment_target, language = :objc) ⇒ Target
Defines a new application target.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xcake/dsl/project/sugar.rb', line 34 def application_for(platform, deployment_target, language = :objc) target do |t| t.type = :application t.platform = platform t.deployment_target = deployment_target t.language = language yield(t) if block_given? end end |
#configure_test_target_for_host_target(test_target, host_target) ⇒ Object (private)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/xcake/dsl/project/sugar.rb', line 95 def configure_test_target_for_host_target(test_target, host_target) test_target.target_dependencies << host_target test_target.platform = host_target.platform test_target.deployment_target = host_target.deployment_target test_target.language = host_target.language return unless host_target.type == :application test_target.all_configurations.each do |c| # Do nothing as they break UITests # For more details https://github.com/jcampbell05/xcake/issues/115 next if test_target.type == :ui_test_bundle c.settings['BUNDLE_LOADER'] = '$(TEST_HOST)' c.settings['TEST_HOST'] = if host_target.platform == :osx "$(BUILT_PRODUCTS_DIR)/#{host_target.name}.app/Contents/MacOS/#{host_target.name}" else "$(BUILT_PRODUCTS_DIR)/#{host_target.name}.app/#{host_target.name}" end end end |
#extension_for(host_target) {|target| ... } ⇒ Target
Defines a extension target.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/xcake/dsl/project/sugar.rb', line 130 def extension_for(host_target) target = target do |t| t.type = :app_extension t.platform = host_target.platform t.deployment_target = host_target.deployment_target t.language = host_target.language end host_target.target_dependencies << target yield(target) if block_given? target end |
#project {|_self| ... } ⇒ Object
Passes the project instance to a block. This is used to easily modify the properties of the project in the DSL.
12 13 14 15 |
# File 'lib/xcake/dsl/project/sugar.rb', line 12 def project yield(self) if block_given? self end |
#target(&block) ⇒ Target
Defines a new target.
65 66 67 68 69 |
# File 'lib/xcake/dsl/project.rb', line 65 def target(&block) target = Target.new(self, &block) targets << target target end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/xcake/dsl/project.rb', line 73 def to_s "Project<#{name}>" end |
#ui_tests_for(host_target) ⇒ Target
Defines a new ui test target.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/xcake/dsl/project/sugar.rb', line 56 def ui_tests_for(host_target) target do |t| t.name = "#{host_target.name}UITests" t.type = :ui_test_bundle configure_test_target_for_host_target(t, host_target) t.all_configurations.each do |c| c.settings['TEST_TARGET_NAME'] = host_target.name end yield(t) if block_given? end end |
#unit_tests_for(host_target) ⇒ Target
Defines a new unit test target.
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/xcake/dsl/project/sugar.rb', line 82 def unit_tests_for(host_target) target do |t| t.name = "#{host_target.name}Tests" t.type = :unit_test_bundle configure_test_target_for_host_target(t, host_target) yield(t) if block_given? end end |
#watch_app_for(host_target, deployment_target, language = :objc) {|watch_app_target, watch_extension_target| ... } ⇒ Object
Defines targets for watch app.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/xcake/dsl/project/sugar.rb', line 155 def watch_app_for(host_target, deployment_target, language = :objc) watch_app_target = target do |t| t.name = "#{host_target.name}-Watch" t.type = :watch2_app t.platform = :watchos t.deployment_target = deployment_target t.language = language end watch_extension_target = target do |t| t.name = "#{host_target.name}-Watch Extension" t.type = :watch2_extension t.platform = :watchos t.deployment_target = deployment_target t.language = language end host_target.target_dependencies << watch_app_target watch_app_target.target_dependencies << watch_extension_target yield(watch_app_target, watch_extension_target) if block_given? nil end |