Class: Xcake::Project
- Includes:
- Hooks, Hooks::InstanceHooks, Configurable, Visitable
- Defined in:
- lib/xcake/project.rb,
lib/xcake/project/hooks.rb,
lib/xcake/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
TODO: Rename to name.
-
#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.
49 50 51 52 53 54 |
# File 'lib/xcake/project.rb', line 49 def initialize(name = 'Project') self.name = name self.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.
24 25 26 |
# File 'lib/xcake/project.rb', line 24 def class_prefix @class_prefix end |
#name ⇒ String
TODO: Rename to name
20 21 22 |
# File 'lib/xcake/project.rb', line 20 def name @name end |
#organization ⇒ String
Returns the name of your organization. This is used by xcode when creating new files.
29 30 31 |
# File 'lib/xcake/project.rb', line 29 def organization @organization end |
Instance Method Details
#accept(visitor) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/xcake/project.rb', line 80 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/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)
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/xcake/project/sugar.rb', line 91 def configure_test_target_for_host_target(test_target, host_target) test_target.platform = host_target.platform test_target.deployment_target = host_target.deployment_target test_target.language = host_target.language host_path = "#{host_target.name}.app/#{host_target.name}" test_target.all_configurations.each do |c| c.settings['TEST_HOST'] = "$(BUILT_PRODUCTS_DIR)/#{host_path}" end test_target.all_configurations.each do |c| c.settings['BUNDLE_LOADER'] = '$(TEST_HOST)' end end |
#extension_for(host_target) {|target| ... } ⇒ Target
Defines a extension target.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/xcake/project/sugar.rb', line 118 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/project/sugar.rb', line 12 def project yield(self) if block_given? self end |
#target(&block) ⇒ Target
Defines a new target.
66 67 68 69 70 |
# File 'lib/xcake/project.rb', line 66 def target(&block) target = Target.new(project, &block) targets << target target end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/xcake/project.rb', line 74 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 |
# File 'lib/xcake/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) yield(t) if block_given? end end |
#unit_tests_for(host_target) ⇒ Target
Defines a new unit test target.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/xcake/project/sugar.rb', line 78 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.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/xcake/project/sugar.rb', line 143 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 |