Class: Xcake::Target

Inherits:
Object show all
Includes:
Configurable, Visitable
Defined in:
lib/xcake/target.rb,
lib/xcake/target/sugar.rb

Overview

This class is used to describe a target for a Xcode project; This forms part of the DSL and is usally stored in files named Cakefile.

Frameworks collapse

Instance Attribute Summary collapse

Attributes included from Configurable

#configurations

Frameworks collapse

Conversion collapse

Instance Method Summary collapse

Methods included from Visitable

#accept

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.

Examples:

Creating a Target.


Target.new do |t|
  t.name "test"
end

Parameters:

  • block (Proc)

    an optional block that configures the project through the DSL.

Yields:

  • (_self)

Yield Parameters:

  • _self (Xcake::Target)

    the object that the method was called on



178
179
180
181
182
183
# File 'lib/xcake/target.rb', line 178

def initialize(project)
  @project = project
  @build_phases = []

  yield(self) if block_given?
end

Instance Attribute Details

#build_phasesArray<Xcodeproj::Project::Object::AbstractBuildPhase>

Returns the list of custom build phases for the project.

Returns:

  • (Array<Xcodeproj::Project::Object::AbstractBuildPhase>)

    the list of custom build phases for the project.



46
47
48
# File 'lib/xcake/target.rb', line 46

def build_phases
  @build_phases
end

#deployment_targetString

Returns the minimum deployment version for the target's platform.

Returns:

  • (String)

    the minimum deployment version for the target's platform.



32
33
34
# File 'lib/xcake/target.rb', line 32

def deployment_target
  @deployment_target
end

#exclude_filesArray or String

Returns files to exclude for the target. Supports regular expressions.

Examples:


spec.exclude_files = ["Classes/**/unused.{h,m}"]

Returns:

  • (Array or String)

    files to exclude for the target. Supports regular expressions



142
143
144
# File 'lib/xcake/target.rb', line 142

def exclude_files
  @exclude_files
end

#include_filesArray or String

Returns files to include for the target. Supports regular expressions, Defaults to: [".//*/*."].

Examples:


spec.include_files = "Classes/**/*.{h,m}"

Returns:

  • (Array or String)

    files to include for the target. Supports regular expressions, Defaults to: [".//*/*."]



133
134
135
# File 'lib/xcake/target.rb', line 133

def include_files
  @include_files
end

#languageString

Returns the language for the target. Can be :objc, :swift.

Returns:

  • (String)

    the language for the target. Can be :objc, :swift.



37
38
39
# File 'lib/xcake/target.rb', line 37

def language
  @language
end

#nameString

Returns the name of the target.

Returns:

  • (String)

    the name of the target.



16
17
18
# File 'lib/xcake/target.rb', line 16

def name
  @name
end

#platformString

Returns the platform for the target. Can be :ios, :osx, :tvos, :watchos.

Returns:

  • (String)

    the platform for the target. Can be :ios, :osx, :tvos, :watchos.



27
28
29
# File 'lib/xcake/target.rb', line 27

def platform
  @platform
end

#projectProject

Returns the project for the target.

Returns:

  • (Project)

    the project for the target.



12
13
14
# File 'lib/xcake/target.rb', line 12

def project
  @project
end

#system_frameworksArray<String>

Returns system frameworks to include for the target Defaults to:

  • ["Foundation", "UIKit"] for iOS
  • ["Cocoa"] for OSX.

Examples:


spec.system_frameworks = ["Foundation"]

Returns:

  • (Array<String>)

    system frameworks to include for the target Defaults to:

    • ["Foundation", "UIKit"] for iOS
    • ["Cocoa"] for OSX


155
156
157
# File 'lib/xcake/target.rb', line 155

def system_frameworks
  @system_frameworks
end

#system_librariesArray<String>

Returns system libraries to include for the target.

Examples:


spec.system_libraries = ["z", "sqlite3"]

Returns:

  • (Array<String>)

    system libraries to include for the target



163
164
165
# File 'lib/xcake/target.rb', line 163

def system_libraries
  @system_libraries
end

#target_dependenciesArray<Target>

Returns targets to use as dependencies.

Returns:



167
168
169
# File 'lib/xcake/target.rb', line 167

def target_dependencies
  @target_dependencies
end

#test_targetTarget

Returns the test target for this target.

Returns:

  • (Target)

    the test target for this target



41
42
43
# File 'lib/xcake/target.rb', line 41

def test_target
  @test_target
end

#typeString

Returns the type of the target. Can be :application, :dynamic_library, framework or :static_library.

Returns:

  • (String)

    the type of the target. Can be :application, :dynamic_library, framework or :static_library.



22
23
24
# File 'lib/xcake/target.rb', line 22

def type
  @type
end

Instance Method Details

#shell_script_build_phase(name, script) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/xcake/target/sugar.rb', line 5

def shell_script_build_phase(name, script)
  phase = ShellScriptBuildPhase.new
  phase.name = name
  phase.script = script.strip_heredoc
  build_phases << phase
  phase
end

#to_sObject



207
208
209
# File 'lib/xcake/target.rb', line 207

def to_s
  "Target<#{name}>"
end