xcodeproj 0.26.3 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,68 @@
1
+ require 'xcodeproj/scheme/abstract_scheme_action'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the LaunchAction node of a .xcscheme XML file
6
+ #
7
+ class LaunchAction < AbstractSchemeAction
8
+ # @param [REXML::Element] node
9
+ # The 'LaunchAction' 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, 'LaunchAction') do
14
+ # Add some attributes (that are not handled by this wrapper class yet but expected in the XML)
15
+ @xml_element.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
16
+ @xml_element.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
17
+ @xml_element.attributes['launchStyle'] = '0'
18
+ @xml_element.attributes['useCustomWorkingDirectory'] = bool_to_string(false)
19
+ @xml_element.attributes['ignoresPersistentStateOnLaunch'] = bool_to_string(false)
20
+ @xml_element.attributes['debugDocumentVersioning'] = bool_to_string(true)
21
+ @xml_element.attributes['debugServiceExtension'] = 'internal'
22
+ @xml_element.add_element('AdditionalOptions')
23
+
24
+ # Setup default values for other (handled) attributes
25
+ self.build_configuration = 'Debug'
26
+ self.allow_location_simulation = true
27
+ end
28
+ end
29
+
30
+ # @todo handle 'launchStyle' attribute
31
+ # @todo handle 'useCustomWorkingDirectory attribute
32
+ # @todo handle 'ignoresPersistentStateOnLaunch' attribute
33
+ # @todo handle 'debugDocumentVersioning' attribute
34
+ # @todo handle 'debugServiceExtension'
35
+
36
+ # @return [Bool]
37
+ # Whether or not to allow GPS location simulation when launching this target
38
+ #
39
+ def allow_location_simulation?
40
+ string_to_bool(@xml_element.attributes['allowLocationSimulation'])
41
+ end
42
+
43
+ # @param [Bool] flag
44
+ # Set whether or not to allow GPS location simulation when launching this target
45
+ #
46
+ def allow_location_simulation=(flag)
47
+ @xml_element.attributes['allowLocationSimulation'] = bool_to_string(flag)
48
+ end
49
+
50
+ # @return [BuildableProductRunnable]
51
+ # The BuildReference to launch when executing the Launch Action
52
+ #
53
+ def buildable_product_runnable
54
+ BuildableProductRunnable.new(@xml_element.elements['BuildableProductRunnable'], 0)
55
+ end
56
+
57
+ # @param [BuildableProductRunnable] runnable
58
+ # Set the BuildableProductRunnable referencing the target to launch
59
+ #
60
+ def buildable_product_runnable=(runnable)
61
+ @xml_element.delete_element('BuildableProductRunnable')
62
+ @xml_element.add_element(runnable.xml_element) if runnable
63
+ end
64
+
65
+ # @todo handle 'AdditionalOptions' tag
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # This class wraps the MacroExpansion node of a .xcscheme XML file
4
+ #
5
+ class MacroExpansion < XMLElementWrapper
6
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
7
+ # Either the Xcode target to reference,
8
+ # or an existing XML 'MacroExpansion' node element
9
+ # or nil to create an empty MacroExpansion object
10
+ #
11
+ def initialize(target_or_node = nil)
12
+ create_xml_element_with_fallback(target_or_node, 'MacroExpansion') do
13
+ self.buildable_reference = BuildableReference.new(target_or_node) if target_or_node
14
+ end
15
+ end
16
+
17
+ # @return [BuildableReference]
18
+ # The BuildableReference this MacroExpansion refers to
19
+ #
20
+ def buildable_reference
21
+ @buildable_reference ||= BuildableReference.new @xml_element.elements['BuildableReference']
22
+ end
23
+
24
+ # @param [BuildableReference] ref
25
+ # Set the BuildableReference this MacroExpansion refers to
26
+ #
27
+ def buildable_reference=(ref)
28
+ @xml_element.delete_element('BuildableReference')
29
+ @xml_element.add_element(ref.xml_element)
30
+ @buildable_reference = ref
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,57 @@
1
+ require 'xcodeproj/scheme/abstract_scheme_action'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the ProfileAction node of a .xcscheme XML file
6
+ #
7
+ class ProfileAction < AbstractSchemeAction
8
+ # @param [REXML::Element] node
9
+ # The 'ProfileAction' 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, 'ProfileAction') do
14
+ # Add some attributes (that are not handled by this wrapper class yet but expected in the XML)
15
+ @xml_element.attributes['savedToolIdentifier'] = ''
16
+ @xml_element.attributes['useCustomWorkingDirectory'] = bool_to_string(false)
17
+ @xml_element.attributes['debugDocumentVersioning'] = bool_to_string(true)
18
+
19
+ # Setup default values for other (handled) attributes
20
+ self.build_configuration = 'Release'
21
+ self.should_use_launch_scheme_args_env = true
22
+ end
23
+ end
24
+
25
+ # @return [Bool]
26
+ # Whether this Profile Action should use the same arguments and environment variables
27
+ # as the Launch Action.
28
+ #
29
+ def should_use_launch_scheme_args_env?
30
+ string_to_bool(@xml_element.attributes['shouldUseLaunchSchemeArgsEnv'])
31
+ end
32
+
33
+ # @param [Bool] flag
34
+ # Set Whether this Profile Action should use the same arguments and environment variables
35
+ # as the Launch Action.
36
+ #
37
+ def should_use_launch_scheme_args_env=(flag)
38
+ @xml_element.attributes['shouldUseLaunchSchemeArgsEnv'] = bool_to_string(flag)
39
+ end
40
+
41
+ # @return [BuildableProductRunnable]
42
+ # The BuildableProductRunnable to launch when launching the Profile action
43
+ #
44
+ def buildable_product_runnable
45
+ BuildableProductRunnable.new @xml_element.elements['BuildableProductRunnable']
46
+ end
47
+
48
+ # @param [BuildableProductRunnable] runnable
49
+ # Set the BuildableProductRunnable referencing the target to launch when profiling
50
+ #
51
+ def buildable_product_runnable=(runnable)
52
+ @xml_element.delete_element('BuildableProductRunnable')
53
+ @xml_element.add_element(runnable.xml_element) if runnable
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,123 @@
1
+ require 'xcodeproj/scheme/abstract_scheme_action'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ # This class wraps the TestAction node of a .xcscheme XML file
6
+ #
7
+ class TestAction < AbstractSchemeAction
8
+ # @param [REXML::Element] node
9
+ # The 'TestAction' 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, 'TestAction') do
14
+ @xml_element.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
15
+ @xml_element.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
16
+ @xml_element.add_element('AdditionalOptions')
17
+ self.should_use_launch_scheme_args_env = true
18
+ self.build_configuration = 'Debug'
19
+ end
20
+ end
21
+
22
+ # @return [Bool]
23
+ # Whether this Test Action should use the same arguments and environment variables
24
+ # as the Launch Action.
25
+ #
26
+ def should_use_launch_scheme_args_env?
27
+ string_to_bool(@xml_element.attributes['shouldUseLaunchSchemeArgsEnv'])
28
+ end
29
+
30
+ # @param [Bool] flag
31
+ # Set Whether this Test Action should use the same arguments and environment variables
32
+ # as the Launch Action.
33
+ #
34
+ def should_use_launch_scheme_args_env=(flag)
35
+ @xml_element.attributes['shouldUseLaunchSchemeArgsEnv'] = bool_to_string(flag)
36
+ end
37
+
38
+ # @return [Array<TestableReference>]
39
+ # The list of TestableReference (test bundles) associated with this Test Action
40
+ #
41
+ def testables
42
+ return [] unless @xml_element.elements['Testables']
43
+
44
+ @xml_element.elements['Testables'].get_elements('TestableReference').map do |node|
45
+ TestableReference.new(node)
46
+ end
47
+ end
48
+
49
+ # @param [TestableReference] testable
50
+ # Add a TestableReference (test bundle) to this Test Action
51
+ #
52
+ def add_testable(testable)
53
+ testables = @xml_element.elements['Testables'] || @xml_element.add_element('Testables')
54
+ testables.add_element(testable.xml_element)
55
+ end
56
+
57
+ # @return [Array<MacroExpansion>]
58
+ # The list of MacroExpansion bound with this TestAction
59
+ #
60
+ def macro_expansions
61
+ @xml_element.get_elements('MacroExpansion').map do |node|
62
+ MacroExpansion.new(node)
63
+ end
64
+ end
65
+
66
+ # @param [MacroExpansion] macro_expansion
67
+ # Add a MacroExpansion to this TestAction
68
+ #
69
+ def add_macro_expansion(macro_expansion)
70
+ @xml_element.add_element(macro_expansion.xml_element)
71
+ end
72
+
73
+ #-------------------------------------------------------------------------#
74
+
75
+ class TestableReference < XMLElementWrapper
76
+ # @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
77
+ # Either the Xcode target to reference,
78
+ # or an existing XML 'TestableReference' node element to reference,
79
+ # or nil to create an new, empty TestableReference
80
+ #
81
+ def initialize(target_or_node = nil)
82
+ create_xml_element_with_fallback(target_or_node, 'TestableReference') do
83
+ self.skipped = false
84
+ add_buildable_reference BuildableReference.new(target_or_node) unless target_or_node.nil?
85
+ end
86
+ end
87
+
88
+ # @return [Bool]
89
+ # Whether or not this TestableReference (test bundle) should be skipped or not
90
+ #
91
+ def skipped?
92
+ string_to_bool(@xml_element.attributes['skipped'])
93
+ end
94
+
95
+ # @param [Bool] flag
96
+ # Set whether or not this TestableReference (test bundle) should be skipped or not
97
+ #
98
+ def skipped=(flag)
99
+ @xml_element.attributes['skipped'] = bool_to_string(flag)
100
+ end
101
+
102
+ # @return [Array<BuildableReference>]
103
+ # The list of BuildableReferences this action will build.
104
+ # (The list usually contains only one element)
105
+ #
106
+ def buildable_references
107
+ @xml_element.get_elements('BuildableReference').map do |node|
108
+ BuildableReference.new(node)
109
+ end
110
+ end
111
+
112
+ # @param [BuildableReference] ref
113
+ # The BuildableReference to add to the list of targets this action will build
114
+ #
115
+ def add_buildable_reference(ref)
116
+ @xml_element.add_element(ref.xml_element)
117
+ end
118
+
119
+ # @todo handle 'AdditionalOptions' tag
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,82 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ # Abstract base class used for other XCScheme classes wrapping an XML element
4
+ #
5
+ class XMLElementWrapper
6
+ # @return [REXML::Element]
7
+ # The XML node wrapped and manipulated by this XMLElementWrapper object
8
+ #
9
+ attr_reader :xml_element
10
+
11
+ # @return [String]
12
+ # The XML representation of the node this XMLElementWrapper wraps,
13
+ # formatted in the same way that Xcode would.
14
+ def to_s
15
+ formatter = XMLFormatter.new(2)
16
+ formatter.compact = false
17
+ out = ''
18
+ formatter.write(@xml_element, out)
19
+ out.gsub!("<?xml version='1.0' encoding='UTF-8'?>", '')
20
+ out << "\n"
21
+ out
22
+ end
23
+
24
+ private
25
+
26
+ # This is a method intended to be used to facilitate the implementation of the initializers.
27
+ #
28
+ # - Create the @xml_element attribute based on the node passed as parameter, only if
29
+ # that parameter is of type REXML::Element and its name matches the tag_name given.
30
+ # - Otherwise, create a brand new REXML::Element with the proper tag name and
31
+ # execute the block given as a fallback to let the caller the chance to configure it
32
+ #
33
+ # @param [REXML::Element, *] node
34
+ # The node this XMLElementWrapper is expected to wrap
35
+ # or any other object (typically an AbstractTarget instance, or nil) the initializer might expect
36
+ #
37
+ # @param [String] tag_name
38
+ # The expected name for the node, which will also be the name used to create the new node
39
+ # if that `node` parameter is not a REXML::Element itself.
40
+ #
41
+ # @yield a parameter-less block if the `node` parameter is not actually a REXML::Element
42
+ #
43
+ # @raise Informative
44
+ # If the `node` parameter is a REXML::Element instance but the node's name
45
+ # doesn't match the one provided by the `tag_name` parameter.
46
+ #
47
+ def create_xml_element_with_fallback(node, tag_name)
48
+ if node && node.is_a?(REXML::Element)
49
+ raise Informative, 'Wrong XML tag name' unless node.name == tag_name
50
+ @xml_element = node
51
+ else
52
+ @xml_element = REXML::Element.new(tag_name)
53
+ yield if block_given?
54
+ end
55
+ end
56
+
57
+ # @param [Bool]
58
+ # The boolean we want to represent as a string
59
+ #
60
+ # @return [String]
61
+ # The string representaiton of that boolean used in the XML ('YES' or 'NO')
62
+ #
63
+ def bool_to_string(flag)
64
+ flag ? 'YES' : 'NO'
65
+ end
66
+
67
+ # @param [String]
68
+ # The string representaiton of a boolean used in the XML ('YES' or 'NO')
69
+ #
70
+ # @return [Bool]
71
+ # The boolean interpretation of that string
72
+ #
73
+ # @raise Informative
74
+ # If the string is not representing a boolean (i.e. is neither 'YES' nor 'NO')
75
+ #
76
+ def string_to_bool(str)
77
+ raise Informative, 'Invalid tag value. Expected YES or NO.' unless %w(YES NO).include?(str)
78
+ str == 'YES'
79
+ end
80
+ end
81
+ end
82
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.3
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-26 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -101,6 +101,17 @@ files:
101
101
  - lib/xcodeproj/project/project_helper.rb
102
102
  - lib/xcodeproj/project/uuid_generator.rb
103
103
  - lib/xcodeproj/scheme.rb
104
+ - lib/xcodeproj/scheme/abstract_scheme_action.rb
105
+ - lib/xcodeproj/scheme/analyze_action.rb
106
+ - lib/xcodeproj/scheme/archive_action.rb
107
+ - lib/xcodeproj/scheme/build_action.rb
108
+ - lib/xcodeproj/scheme/buildable_product_runnable.rb
109
+ - lib/xcodeproj/scheme/buildable_reference.rb
110
+ - lib/xcodeproj/scheme/launch_action.rb
111
+ - lib/xcodeproj/scheme/macro_expansion.rb
112
+ - lib/xcodeproj/scheme/profile_action.rb
113
+ - lib/xcodeproj/scheme/test_action.rb
114
+ - lib/xcodeproj/scheme/xml_element_wrapper.rb
104
115
  - lib/xcodeproj/user_interface.rb
105
116
  - lib/xcodeproj/workspace.rb
106
117
  - lib/xcodeproj/workspace/file_reference.rb