xcodeproj 0.26.3 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xcodeproj/config.rb +2 -1
- data/lib/xcodeproj/constants.rb +12 -5
- data/lib/xcodeproj/gem_version.rb +1 -1
- data/lib/xcodeproj/project/object.rb +1 -1
- data/lib/xcodeproj/project/object/group.rb +2 -2
- data/lib/xcodeproj/scheme.rb +174 -137
- data/lib/xcodeproj/scheme/abstract_scheme_action.rb +26 -0
- data/lib/xcodeproj/scheme/analyze_action.rb +19 -0
- data/lib/xcodeproj/scheme/archive_action.rb +59 -0
- data/lib/xcodeproj/scheme/build_action.rb +186 -0
- data/lib/xcodeproj/scheme/buildable_product_runnable.rb +55 -0
- data/lib/xcodeproj/scheme/buildable_reference.rb +111 -0
- data/lib/xcodeproj/scheme/launch_action.rb +68 -0
- data/lib/xcodeproj/scheme/macro_expansion.rb +34 -0
- data/lib/xcodeproj/scheme/profile_action.rb +57 -0
- data/lib/xcodeproj/scheme/test_action.rb +123 -0
- data/lib/xcodeproj/scheme/xml_element_wrapper.rb +82 -0
- metadata +13 -2
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'xcodeproj/scheme/xml_element_wrapper'
|
2
|
+
|
3
|
+
module Xcodeproj
|
4
|
+
class XCScheme
|
5
|
+
# This abstract class aims to be the base class for every XxxAction class
|
6
|
+
# that have a #build_configuration attribute
|
7
|
+
#
|
8
|
+
class AbstractSchemeAction < XMLElementWrapper
|
9
|
+
# @return [String]
|
10
|
+
# The build configuration associated with this action
|
11
|
+
# (usually either 'Debug' or 'Release')
|
12
|
+
#
|
13
|
+
def build_configuration
|
14
|
+
@xml_element.attributes['buildConfiguration']
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param [String] config_name
|
18
|
+
# The build configuration to associate with this action
|
19
|
+
# (usually either 'Debug' or 'Release')
|
20
|
+
#
|
21
|
+
def build_configuration=(config_name)
|
22
|
+
@xml_element.attributes['buildConfiguration'] = config_name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'xcodeproj/scheme/abstract_scheme_action'
|
2
|
+
|
3
|
+
module Xcodeproj
|
4
|
+
class XCScheme
|
5
|
+
# This class wraps the AnalyzeAction node of a .xcscheme XML file
|
6
|
+
#
|
7
|
+
class AnalyzeAction < AbstractSchemeAction
|
8
|
+
# @param [REXML::Element] node
|
9
|
+
# The 'AnalyzeAction' XML node that this object will wrap.
|
10
|
+
# If nil, will create a default XML node to use.
|
11
|
+
#
|
12
|
+
def initialize(node = nil)
|
13
|
+
create_xml_element_with_fallback(node, 'AnalyzeAction') do
|
14
|
+
self.build_configuration = 'Debug'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'xcodeproj/scheme/abstract_scheme_action'
|
2
|
+
|
3
|
+
module Xcodeproj
|
4
|
+
class XCScheme
|
5
|
+
# This class wraps the ArchiveAction node of a .xcscheme XML file
|
6
|
+
#
|
7
|
+
class ArchiveAction < AbstractSchemeAction
|
8
|
+
# @param [REXML::Element] node
|
9
|
+
# The 'ArchiveAction' XML node that this object will wrap.
|
10
|
+
# If nil, will create a default XML node to use.
|
11
|
+
#
|
12
|
+
def initialize(node = nil)
|
13
|
+
create_xml_element_with_fallback(node, 'ArchiveAction') do
|
14
|
+
self.build_configuration = 'Release'
|
15
|
+
self.reveal_archive_in_organizer = true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Bool]
|
20
|
+
# Whether the Archive will be revealed in Xcode's Organizer
|
21
|
+
# after it's done building.
|
22
|
+
#
|
23
|
+
def reveal_archive_in_organizer?
|
24
|
+
string_to_bool(@xml_element.attributes['revealArchiveInOrganizer'])
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [Bool] flag
|
28
|
+
# Set whether the Archive will be revealed in Xcode's Organizer
|
29
|
+
# after it's done building.
|
30
|
+
#
|
31
|
+
def reveal_archive_in_organizer=(flag)
|
32
|
+
@xml_element.attributes['revealArchiveInOrganizer'] = bool_to_string(flag)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
# The custom name to give to the archive.
|
37
|
+
# If nil, the generated archive will have the same name as the one
|
38
|
+
# set in the associated target's Build Settings for the built product.
|
39
|
+
#
|
40
|
+
def custom_archive_name
|
41
|
+
@xml_element.attributes['customArchiveName']
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param [String] name
|
45
|
+
# Set the custom name to use for the built archive
|
46
|
+
# If nil, the customization of the archive name will be removed and
|
47
|
+
# the generated archive will have the same name as the one set in the
|
48
|
+
# associated target's Build Settings for the build product.
|
49
|
+
#
|
50
|
+
def custom_archive_name=(name)
|
51
|
+
if name
|
52
|
+
@xml_element.attributes['customArchiveName'] = name
|
53
|
+
else
|
54
|
+
@xml_element.delete_attribute('customArchiveName')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require 'xcodeproj/scheme/xml_element_wrapper'
|
2
|
+
|
3
|
+
module Xcodeproj
|
4
|
+
class XCScheme
|
5
|
+
# This class wraps the BuildAction node of a .xcscheme XML file
|
6
|
+
#
|
7
|
+
# Note: It's not a AbstractSchemeAction like the others because it is
|
8
|
+
# a special case of action (with no build_configuration, etc)
|
9
|
+
#
|
10
|
+
class BuildAction < XMLElementWrapper
|
11
|
+
# @param [REXML::Element] node
|
12
|
+
# The 'BuildAction' XML node that this object will wrap.
|
13
|
+
# If nil, will create a default XML node to use.
|
14
|
+
#
|
15
|
+
def initialize(node = nil)
|
16
|
+
create_xml_element_with_fallback(node, 'BuildAction') do
|
17
|
+
self.parallelize_buildables = true
|
18
|
+
self.build_implicit_dependencies = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Bool]
|
23
|
+
# Whether or not to build the various targets in parallel
|
24
|
+
#
|
25
|
+
def parallelize_buildables?
|
26
|
+
string_to_bool(@xml_element.attributes['parallelizeBuildables'])
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param [Bool] flag
|
30
|
+
# Set whether or not to build the various targets in parallel
|
31
|
+
#
|
32
|
+
def parallelize_buildables=(flag)
|
33
|
+
@xml_element.attributes['parallelizeBuildables'] = bool_to_string(flag)
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Bool]
|
37
|
+
# Whether or not to detect and build implicit dependencies for each target
|
38
|
+
#
|
39
|
+
def build_implicit_dependencies?
|
40
|
+
string_to_bool(@xml_element.attributes['buildImplicitDependencies'])
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [Bool] flag
|
44
|
+
# Whether or not to detect and build implicit dependencies for each target
|
45
|
+
#
|
46
|
+
def build_implicit_dependencies=(flag)
|
47
|
+
@xml_element.attributes['buildImplicitDependencies'] = bool_to_string(flag)
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Array<BuildAction::Entry>]
|
51
|
+
# The list of BuildActionEntry nodes associated with this Build Action.
|
52
|
+
# Each entry represent a target to build and tells for which action it's needed to be built.
|
53
|
+
#
|
54
|
+
def entries
|
55
|
+
@xml_element.elements['BuildActionEntries'].get_elements('BuildActionEntry').map do |entry_node|
|
56
|
+
BuildAction::Entry.new(entry_node)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# @param [BuildAction::Entry] entry
|
61
|
+
# The BuildActionEntry to add to the list of targets to build for the various actions
|
62
|
+
#
|
63
|
+
def add_entry(entry)
|
64
|
+
entries = @xml_element.elements['BuildActionEntries'] || @xml_element.add_element('BuildActionEntries')
|
65
|
+
entries.add_element(entry.xml_element)
|
66
|
+
end
|
67
|
+
|
68
|
+
#-------------------------------------------------------------------------#
|
69
|
+
|
70
|
+
class Entry < XMLElementWrapper
|
71
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
|
72
|
+
# Either the Xcode target to reference,
|
73
|
+
# or an existing XML 'BuildActionEntry' node element to reference,
|
74
|
+
# or nil to create an new, empty Entry with default values
|
75
|
+
#
|
76
|
+
def initialize(target_or_node = nil)
|
77
|
+
create_xml_element_with_fallback(target_or_node, 'BuildActionEntry') do
|
78
|
+
# Check target type to configure the default entry attributes accordingly
|
79
|
+
is_test_target, is_app_target = [false, false]
|
80
|
+
if target_or_node && target_or_node.is_a?(::Xcodeproj::Project::Object::PBXNativeTarget)
|
81
|
+
test_types = [Constants::PRODUCT_TYPE_UTI[:octest_bundle], Constants::PRODUCT_TYPE_UTI[:unit_test_bundle]]
|
82
|
+
app_types = [Constants::PRODUCT_TYPE_UTI[:application]]
|
83
|
+
is_test_target = test_types.include?(target_or_node.product_type)
|
84
|
+
is_app_target = app_types.include?(target_or_node.product_type)
|
85
|
+
end
|
86
|
+
|
87
|
+
self.build_for_analyzing = true
|
88
|
+
self.build_for_testing = is_test_target
|
89
|
+
self.build_for_running = is_app_target
|
90
|
+
self.build_for_profiling = is_app_target
|
91
|
+
self.build_for_archiving = is_app_target
|
92
|
+
|
93
|
+
add_buildable_reference BuildableReference.new(target_or_node) if target_or_node
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# @return [Bool]
|
98
|
+
# Whether or not to build this target when building for Testing
|
99
|
+
#
|
100
|
+
def build_for_testing?
|
101
|
+
string_to_bool(@xml_element.attributes['buildForTesting'])
|
102
|
+
end
|
103
|
+
|
104
|
+
# @param [Bool]
|
105
|
+
# Set whether or not to build this target when building for Testing
|
106
|
+
#
|
107
|
+
def build_for_testing=(flag)
|
108
|
+
@xml_element.attributes['buildForTesting'] = bool_to_string(flag)
|
109
|
+
end
|
110
|
+
|
111
|
+
# @return [Bool]
|
112
|
+
# Whether or not to build this target when building for Running
|
113
|
+
#
|
114
|
+
def build_for_running?
|
115
|
+
string_to_bool(@xml_element.attributes['buildForRunning'])
|
116
|
+
end
|
117
|
+
|
118
|
+
# @param [Bool]
|
119
|
+
# Set whether or not to build this target when building for Running
|
120
|
+
#
|
121
|
+
def build_for_running=(flag)
|
122
|
+
@xml_element.attributes['buildForRunning'] = bool_to_string(flag)
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [Bool]
|
126
|
+
# Whether or not to build this target when building for Profiling
|
127
|
+
#
|
128
|
+
def build_for_profiling?
|
129
|
+
string_to_bool(@xml_element.attributes['buildForProfiling'])
|
130
|
+
end
|
131
|
+
|
132
|
+
# @param [Bool]
|
133
|
+
# Set whether or not to build this target when building for Profiling
|
134
|
+
#
|
135
|
+
def build_for_profiling=(flag)
|
136
|
+
@xml_element.attributes['buildForProfiling'] = bool_to_string(flag)
|
137
|
+
end
|
138
|
+
|
139
|
+
# @return [Bool]
|
140
|
+
# Whether or not to build this target when building for Archiving
|
141
|
+
#
|
142
|
+
def build_for_archiving?
|
143
|
+
string_to_bool(@xml_element.attributes['buildForArchiving'])
|
144
|
+
end
|
145
|
+
|
146
|
+
# @param [Bool]
|
147
|
+
# Set whether or not to build this target when building for Archiving
|
148
|
+
#
|
149
|
+
def build_for_archiving=(flag)
|
150
|
+
@xml_element.attributes['buildForArchiving'] = bool_to_string(flag)
|
151
|
+
end
|
152
|
+
|
153
|
+
# @return [Bool]
|
154
|
+
# Whether or not to build this target when building for Analyzing
|
155
|
+
#
|
156
|
+
def build_for_analyzing?
|
157
|
+
string_to_bool(@xml_element.attributes['buildForAnalyzing'])
|
158
|
+
end
|
159
|
+
|
160
|
+
# @param [Bool]
|
161
|
+
# Set whether or not to build this target when building for Analyzing
|
162
|
+
#
|
163
|
+
def build_for_analyzing=(flag)
|
164
|
+
@xml_element.attributes['buildForAnalyzing'] = bool_to_string(flag)
|
165
|
+
end
|
166
|
+
|
167
|
+
# @return [Array<BuildableReference>]
|
168
|
+
# The list of BuildableReferences this entry will build.
|
169
|
+
# (The list usually contains only one element)
|
170
|
+
#
|
171
|
+
def buildable_references
|
172
|
+
@xml_element.get_elements('BuildableReference').map do |node|
|
173
|
+
BuildableReference.new(node)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# @param [BuildableReference] ref
|
178
|
+
# The BuildableReference to add to the list of targets this entry will build
|
179
|
+
#
|
180
|
+
def add_buildable_reference(ref)
|
181
|
+
@xml_element.add_element(ref.xml_element)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Xcodeproj
|
2
|
+
class XCScheme
|
3
|
+
# This class wraps the BuildableProductRunnable node of a .xcscheme XML file
|
4
|
+
#
|
5
|
+
# A BuildableProductRunnable is a product that is both buildable
|
6
|
+
# (it contains a BuildableReference) and runnable (it can be launched and debugged)
|
7
|
+
#
|
8
|
+
class BuildableProductRunnable < XMLElementWrapper
|
9
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
|
10
|
+
# Either the Xcode target to reference,
|
11
|
+
# or an existing XML 'BuildableProductRunnable' node element to reference
|
12
|
+
# or nil to create an new, empty BuildableProductRunnable
|
13
|
+
#
|
14
|
+
# @param [#to_s] runnable_debugging_mode
|
15
|
+
# The debugging mode (usually '0')
|
16
|
+
#
|
17
|
+
def initialize(target_or_node = nil, runnable_debugging_mode = nil)
|
18
|
+
create_xml_element_with_fallback(target_or_node, 'BuildableProductRunnable') do
|
19
|
+
self.buildable_reference = BuildableReference.new(target_or_node) if target_or_node
|
20
|
+
@xml_element.attributes['runnableDebuggingMode'] = runnable_debugging_mode.to_s if runnable_debugging_mode
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String]
|
25
|
+
# The Runnable debugging mode (usually either empty or equal to '0')
|
26
|
+
#
|
27
|
+
def runnable_debugging_mode
|
28
|
+
@xml_element.attributes['runnableDebuggingMode']
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param [String] value
|
32
|
+
# Set the runnable debugging mode of this buildable product runnable
|
33
|
+
#
|
34
|
+
def runnable_debugging_mode=(value)
|
35
|
+
@xml_element.attributes['runnableDebuggingMode'] = value.to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [BuildableReference]
|
39
|
+
# The Buildable Reference this Buildable Product Runnable is gonna build and run
|
40
|
+
#
|
41
|
+
def buildable_reference
|
42
|
+
@buildable_reference ||= BuildableReference.new @xml_element.elements['BuildableReference']
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param [BuildableReference] ref
|
46
|
+
# Set the Buildable Reference this Buildable Product Runnable is gonna build and run
|
47
|
+
#
|
48
|
+
def buildable_reference=(ref)
|
49
|
+
@xml_element.delete_element('BuildableReference')
|
50
|
+
@xml_element.add_element(ref.xml_element)
|
51
|
+
@buildable_reference = ref
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Xcodeproj
|
2
|
+
class XCScheme
|
3
|
+
# This class wraps the BuildableReference node of a .xcscheme XML file
|
4
|
+
#
|
5
|
+
# A BuildableReference is a reference to a buildable product (which is
|
6
|
+
# typically is synonymous for an Xcode target)
|
7
|
+
#
|
8
|
+
class BuildableReference < XMLElementWrapper
|
9
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
|
10
|
+
# Either the Xcode target to reference,
|
11
|
+
# or an existing XML 'BuildableReference' node element to reference
|
12
|
+
#
|
13
|
+
def initialize(target_or_node)
|
14
|
+
create_xml_element_with_fallback(target_or_node, 'BuildableReference') do
|
15
|
+
@xml_element.attributes['BuildableIdentifier'] = 'primary'
|
16
|
+
set_reference_target(target_or_node, true) if target_or_node
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
# The name of the target this Buildable Reference points to
|
22
|
+
#
|
23
|
+
def target_name
|
24
|
+
@xml_element.attributes['BlueprintName']
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
# The Unique Identifier of the target (target.uuid) this Buildable Reference points to.
|
29
|
+
#
|
30
|
+
# @note You can use this to `#find` the `Xcodeproj::Project::Object::AbstractTarget`
|
31
|
+
# instance in your Xcodeproj::Project object.
|
32
|
+
# e.g. `project.targets.find { |t| t.uuid == ref.target_uuid }`
|
33
|
+
#
|
34
|
+
def target_uuid
|
35
|
+
@xml_element.attributes['BlueprintIdentifier']
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
# The string representing the container of that target.
|
40
|
+
# Typically in the form of 'container:xxxx.xcodeproj'
|
41
|
+
#
|
42
|
+
def target_referenced_container
|
43
|
+
@xml_element.attributes['ReferencedContainer']
|
44
|
+
end
|
45
|
+
|
46
|
+
# Set the BlueprintIdentifier (target.uuid), BlueprintName (target.name)
|
47
|
+
# and TerefencedContainer (URI pointing to target's projet) all at once
|
48
|
+
#
|
49
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget] target
|
50
|
+
# The target this BuildableReference refers to.
|
51
|
+
#
|
52
|
+
# @param [Bool] override_buildable_name
|
53
|
+
# If true, buildable_name will also be updated by computing a name from the target
|
54
|
+
#
|
55
|
+
def set_reference_target(target, override_buildable_name = false)
|
56
|
+
@xml_element.attributes['BlueprintIdentifier'] = target.uuid
|
57
|
+
@xml_element.attributes['BlueprintName'] = target.name
|
58
|
+
@xml_element.attributes['ReferencedContainer'] = construct_referenced_container_uri(target)
|
59
|
+
self.buildable_name = construct_buildable_name(target) if override_buildable_name
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String]
|
63
|
+
# The name of the final product when building this Buildable Reference
|
64
|
+
#
|
65
|
+
def buildable_name
|
66
|
+
@xml_element.attributes['BuildableName']
|
67
|
+
end
|
68
|
+
|
69
|
+
# @param [String] value
|
70
|
+
# Set the name of the final product when building this Buildable Reference
|
71
|
+
#
|
72
|
+
def buildable_name=(value)
|
73
|
+
@xml_element.attributes['BuildableName'] = value
|
74
|
+
end
|
75
|
+
|
76
|
+
#-------------------------------------------------------------------------#
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
# @!group Private helpers
|
81
|
+
|
82
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget] target
|
83
|
+
#
|
84
|
+
# @return [String] The buildable name of the scheme.
|
85
|
+
#
|
86
|
+
def construct_buildable_name(build_target)
|
87
|
+
case build_target.isa
|
88
|
+
when 'PBXNativeTarget'
|
89
|
+
File.basename(build_target.product_reference.path)
|
90
|
+
when 'PBXAggregateTarget'
|
91
|
+
build_target.name
|
92
|
+
else
|
93
|
+
raise ArgumentError, "Unsupported build target type #{build_target.isa}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param [Xcodeproj::Project::Object::AbstractTarget] target
|
98
|
+
#
|
99
|
+
# @return [String] A string in the format "container:[path to the project
|
100
|
+
# file relative to the project_dir_path, always ending with
|
101
|
+
# the actual project directory name]"
|
102
|
+
#
|
103
|
+
def construct_referenced_container_uri(target)
|
104
|
+
project = target.project
|
105
|
+
relative_path = project.path.relative_path_from(project.path + project.root_object.project_dir_path).to_s
|
106
|
+
relative_path = project.path.basename if relative_path == '.'
|
107
|
+
"container:#{relative_path}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|