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.
-
#project {|_self| ... } ⇒ Object
Passes the project instance to a block.
-
#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
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/xcake/project.rb', line 81 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 |
#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 71 |
# File 'lib/xcake/project.rb', line 66 def target(&block) target = Target.new(project, &block) targets << target target end |
#to_s ⇒ Object
75 76 77 |
# File 'lib/xcake/project.rb', line 75 def to_s "Project<#{name}>" end |
#unit_tests_for(host_target) ⇒ Target
Defines a new unit test target.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/xcake/project/sugar.rb', line 56 def unit_tests_for(host_target) target do |t| t.name = "#{host_target.name}Tests" t.type = :unit_test_bundle t.platform = host_target.platform t.deployment_target = host_target.deployment_target t.language = host_target.language host_path = "#{host_target.name}.app/#{host_target.name}" t.all_configurations.each do |c| c.settings['TEST_HOST'] = "$(BUILT_PRODUCTS_DIR)/#{host_path}" end t.all_configurations.each do |c| c.settings['BUNDLE_LOADER'] = '$(TEST_HOST)' end 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.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/xcake/project/sugar.rb', line 87 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 |