xcodeproj 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80889f1543d932a364554166034555b0838ab081
4
- data.tar.gz: 67b60068200d0226b81fb02441ad0a61919588b9
3
+ metadata.gz: 483500148fe17ee6fba34b974409c1315347f096
4
+ data.tar.gz: dbda0068b785df5bda02f297d677737de8a6e604
5
5
  SHA512:
6
- metadata.gz: f4a9cbd8cdece69a9118f93eaebccf888448db9bd67c3af3e7fa0cc0375339ae70683d48a3db6af5c4f1df44726e13da47f9f41119bc6ef5d7483d0e64a7e852
7
- data.tar.gz: 7f96eb1680c4ad7e70cb9318266204fb03e88f81bfda553420bef222b93ab01043a7204f47efed0e89ee3b6c6f1ff100b92b90408a85c117a5dbf01744c22358
6
+ metadata.gz: f263348b6d8ebfd90c70a74ac61e8bf9c7d6b69c469cfdb6a094d114d30dd8236863b448924bc33bb956f7bdfc8a3575813f93d6103017c0980308eaa6199cf8
7
+ data.tar.gz: 89b9daa36a81cc4486b12324f2b48ebde2713902c2f0cb7318b85900e893f6107d565c0c60b6ee2f529fca98324b423e97a026cfd414d8a4aeafd9b24a0032eb
@@ -7,7 +7,7 @@ module Xcodeproj
7
7
  If no `PROJECT' is specified then the current work directory is searched for one.
8
8
  eos
9
9
 
10
- self.summary = 'Sorts the give project.'
10
+ self.summary = 'Sorts the given project.'
11
11
 
12
12
  self.arguments = [
13
13
  CLAide::Argument.new('PROJECT', false),
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '1.3.1'.freeze unless defined? Xcodeproj::VERSION
4
+ VERSION = '1.3.2'.freeze unless defined? Xcodeproj::VERSION
5
5
  end
@@ -1,35 +1,6 @@
1
+
1
2
  module Xcodeproj
2
3
  module Plist
3
- module Extensions
4
- # Since Xcode 8 beta 4, calling `PBXProject.projectWithFile` breaks subsequent calls to
5
- # `chdir`. While sounding ridiculous, this is unfortunately true and debugging it from the
6
- # userland side showed no difference at all to successful calls to `chdir`, but the working
7
- # directory is simply not changed in the end. This workaround is even more absurd, monkey
8
- # patching all calls to `chdir` to use `__pthread_chdir` which appears to work.
9
- module Dir
10
- def self.chdir(path)
11
- old_dir = Dir.getwd
12
- res = actually_chdir(path)
13
-
14
- if block_given?
15
- begin
16
- return yield
17
- ensure
18
- actually_chdir(old_dir)
19
- end
20
- end
21
-
22
- res
23
- end
24
-
25
- def self.actually_chdir(path)
26
- libc = Fiddle.dlopen '/usr/lib/libc.dylib'
27
- f = Fiddle::Function.new(libc['__pthread_chdir'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
28
- f.call(path.to_s)
29
- end
30
- end
31
- end
32
-
33
4
  # Provides support for loading and serializing property list files via
34
5
  # Fiddle and CoreFoundation / Xcode.
35
6
  #
@@ -171,7 +142,10 @@ module Xcodeproj
171
142
  end
172
143
 
173
144
  def monkey_patch_chdir
174
- Dir.send(:include, Extensions::Dir)
145
+ require 'xcodeproj/plist/ffi/chdir_override'
146
+ class << Dir
147
+ alias_method :chdir, :cp_chdir
148
+ end
175
149
  end
176
150
  end
177
151
  end
@@ -0,0 +1,27 @@
1
+ # Since Xcode 8 beta 4, calling `PBXProject.projectWithFile` breaks subsequent calls to
2
+ # `chdir`. While sounding ridiculous, this is unfortunately true and debugging it from the
3
+ # userland side showed no difference at all to successful calls to `chdir`, but the working
4
+ # directory is simply not changed in the end. This workaround is even more absurd, monkey
5
+ # patching all calls to `chdir` to use `__pthread_chdir` which appears to work.
6
+ class Dir
7
+ def self.cp_chdir(path)
8
+ old_dir = Dir.getwd
9
+ res = cp_actually_chdir(path)
10
+
11
+ if block_given?
12
+ begin
13
+ return yield
14
+ ensure
15
+ cp_actually_chdir(old_dir)
16
+ end
17
+ end
18
+
19
+ res
20
+ end
21
+
22
+ def self.cp_actually_chdir(path)
23
+ libc = Fiddle.dlopen '/usr/lib/libc.dylib'
24
+ f = Fiddle::Function.new(libc['__pthread_chdir'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
25
+ f.call(path.to_s)
26
+ end
27
+ end
@@ -1,4 +1,6 @@
1
1
  require 'xcodeproj/scheme/xml_element_wrapper'
2
+ require 'xcodeproj/scheme/environment_variables'
3
+ require 'xcodeproj/scheme/command_line_arguments'
2
4
 
3
5
  module Xcodeproj
4
6
  class XCScheme
@@ -0,0 +1,162 @@
1
+ require 'xcodeproj/scheme/xml_element_wrapper'
2
+
3
+ module Xcodeproj
4
+ class XCScheme
5
+ COMMAND_LINE_ARGS_NODE = 'CommandLineArguments'.freeze
6
+ COMMAND_LINE_ARG_NODE = 'CommandLineArgument'.freeze
7
+
8
+ # This class wraps the CommandLineArguments node of a .xcscheme XML file. This
9
+ # is just a container of CommandLineArgument objects. It can either appear on a
10
+ # LaunchAction or TestAction scheme group.
11
+ #
12
+ class CommandLineArguments < XMLElementWrapper
13
+ # @param [nil,REXML::Element,Array<CommandLineArgument>,Array<Hash{Symbol => String,Bool}>] node_or_arguments
14
+ # The 'CommandLineArguments' XML node, or list of command line arguments, that this object represents.
15
+ # - If nil, an empty 'CommandLineArguments' XML node will be created
16
+ # - If an REXML::Element, it must be named 'CommandLineArguments'
17
+ # - If an Array of objects or Hashes, they'll each be passed to {#assign_argument}
18
+ #
19
+ def initialize(node_or_arguments = nil)
20
+ create_xml_element_with_fallback(node_or_arguments, COMMAND_LINE_ARGS_NODE) do
21
+ @all_arguments = []
22
+ node_or_arguments.each { |var| assign_argument(var) } unless node_or_arguments.nil?
23
+ end
24
+ end
25
+
26
+ # @return [Array<CommandLineArgument>]
27
+ # The key value pairs currently set in @xml_element
28
+ #
29
+ def all_arguments
30
+ @all_arguments ||= @xml_element.get_elements(COMMAND_LINE_ARG_NODE).map { |argument| CommandLineArgument.new(argument) }
31
+ end
32
+
33
+ # Adds a given argument to the set of command line arguments, or replaces it if that key already exists
34
+ #
35
+ # @param [CommandLineArgument,Hash{Symbol => String,Bool}] argument
36
+ # The argument to add or update, backed by an CommandLineArgument node.
37
+ # - If an CommandLineArgument, the previous reference will still be valid
38
+ # - If a Hash, must conform to {CommandLineArgument#initialize} requirements
39
+ # @return [Array<CommandLineArgument>]
40
+ # The new set of command line arguments after addition
41
+ #
42
+ def assign_argument(argument)
43
+ command_line_arg = if argument.is_a?(CommandLineArgument)
44
+ argument
45
+ else
46
+ CommandLineArgument.new(argument)
47
+ end
48
+ all_arguments.each { |existing_var| remove_argument(existing_var) if existing_var.argument == command_line_arg.argument }
49
+ @xml_element.add_element(command_line_arg.xml_element)
50
+ @all_arguments << command_line_arg
51
+ end
52
+
53
+ # Removes a specified argument (by string or object) from the set of command line arguments
54
+ #
55
+ # @param [CommandLineArgument,String] argument
56
+ # The argument to remove
57
+ # @return [Array<CommandLineArgument>]
58
+ # The new set of command line arguments after removal
59
+ #
60
+ def remove_argument(argument)
61
+ command_line_arg = if argument.is_a?(CommandLineArgument)
62
+ argument
63
+ else
64
+ CommandLineArgument.new(argument)
65
+ end
66
+ raise "Unexpected parameter type: #{command_line_arg.class}" unless command_line_arg.is_a?(CommandLineArgument)
67
+ @xml_element.delete_element(command_line_arg.xml_element)
68
+ @all_arguments -= [command_line_arg]
69
+ end
70
+
71
+ # @param [String] key
72
+ # The key to lookup
73
+ # @return [CommandLineArgument] argument
74
+ # Returns the matching command line argument for a specified key
75
+ #
76
+ def [](argument)
77
+ all_arguments.find { |var| var.argument == argument }
78
+ end
79
+
80
+ # Assigns a value for a specified key
81
+ #
82
+ # @param [String] key
83
+ # The key to update in the command line arguments
84
+ # @param [String] value
85
+ # The value to lookup
86
+ # @return [CommandLineArgument] argument
87
+ # The newly updated command line argument
88
+ #
89
+ def []=(argument, enabled)
90
+ assign_argument(:argument => argument, :enabled => enabled)
91
+ self[argument]
92
+ end
93
+
94
+ # @return [Array<Hash{Symbol => String,Bool}>]
95
+ # The current command line arguments represented as an array
96
+ #
97
+ def to_a
98
+ all_arguments.map(&:to_h)
99
+ end
100
+ end
101
+
102
+ # This class wraps the CommandLineArgument node of a .xcscheme XML file.
103
+ # Environment arguments are accessible via the NSDictionary returned from
104
+ # [[NSProcessInfo processInfo] arguments] in your app code.
105
+ #
106
+ class CommandLineArgument < XMLElementWrapper
107
+ # @param [nil,REXML::Element,Hash{Symbol => String,Bool}] node_or_argument
108
+ # - If nil, it will create a default XML node to use
109
+ # - If a REXML::Element, should be a <CommandLineArgument> XML node to wrap
110
+ # - If a Hash, must contain keys :key and :value (Strings) and optionally :enabled (Boolean)
111
+ #
112
+ def initialize(node_or_argument)
113
+ create_xml_element_with_fallback(node_or_argument, COMMAND_LINE_ARG_NODE) do
114
+ raise "Must pass a Hash with 'argument' and 'enabled'!" unless node_or_argument.is_a?(Hash) &&
115
+ node_or_argument.key?(:argument) && node_or_argument.key?(:enabled)
116
+
117
+ @xml_element.attributes['argument'] = node_or_argument[:argument]
118
+ @xml_element.attributes['isEnabled'] = if node_or_argument.key?(:enabled)
119
+ bool_to_string(node_or_argument[:enabled])
120
+ else
121
+ bool_to_string(false)
122
+ end
123
+ end
124
+ end
125
+
126
+ # Returns the CommandLineArgument's key
127
+ # @return [String]
128
+ #
129
+ def argument
130
+ @xml_element.attributes['argument']
131
+ end
132
+
133
+ # Sets the CommandLineArgument's key
134
+ # @param [String] key
135
+ #
136
+ def argument=(argument)
137
+ @xml_element.attributes['argument'] = argument
138
+ end
139
+
140
+ # Returns the CommandLineArgument's enabled state
141
+ # @return [Bool]
142
+ #
143
+ def enabled
144
+ string_to_bool(@xml_element.attributes['isEnabled'])
145
+ end
146
+
147
+ # Sets the CommandLineArgument's enabled state
148
+ # @param [Bool] enabled
149
+ #
150
+ def enabled=(enabled)
151
+ @xml_element.attributes['isEnabled'] = bool_to_string(enabled)
152
+ end
153
+
154
+ # @return [Hash{:key => String, :value => String, :enabled => Bool}]
155
+ # The command line argument XML node with attributes converted to a representative Hash
156
+ #
157
+ def to_h
158
+ { :argument => argument, :enabled => enabled }
159
+ end
160
+ end
161
+ end
162
+ end
@@ -79,6 +79,22 @@ module Xcodeproj
79
79
  end
80
80
 
81
81
  # @todo handle 'AdditionalOptions' tag
82
+
83
+ # @return [CommandLineArguments]
84
+ # Returns the CommandLineArguments that will be passed at app launch
85
+ #
86
+ def command_line_arguments
87
+ CommandLineArguments.new(@xml_element.elements[XCScheme::COMMAND_LINE_ARGS_NODE])
88
+ end
89
+
90
+ # @return [CommandLineArguments] arguments
91
+ # Sets the CommandLineArguments that will be passed at app launch
92
+ #
93
+ def command_line_arguments=(arguments)
94
+ @xml_element.delete_element(XCScheme::COMMAND_LINE_ARGS_NODE)
95
+ @xml_element.add_element(arguments.xml_element) if arguments
96
+ arguments
97
+ end
82
98
  end
83
99
  end
84
100
  end
@@ -1,5 +1,4 @@
1
1
  require 'xcodeproj/scheme/abstract_scheme_action'
2
- require 'xcodeproj/scheme/environment_variables'
3
2
 
4
3
  module Xcodeproj
5
4
  class XCScheme
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: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: 1.0.1
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '2.0'
@@ -54,7 +54,7 @@ dependencies:
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- version: 1.0.0
57
+ version: 1.0.1
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '2.0'
@@ -85,6 +85,7 @@ files:
85
85
  - lib/xcodeproj/helper.rb
86
86
  - lib/xcodeproj/plist.rb
87
87
  - lib/xcodeproj/plist/ffi.rb
88
+ - lib/xcodeproj/plist/ffi/chdir_override.rb
88
89
  - lib/xcodeproj/plist/ffi/core_foundation.rb
89
90
  - lib/xcodeproj/plist/ffi/dev_tools_core.rb
90
91
  - lib/xcodeproj/plist/plist_gem.rb
@@ -117,6 +118,7 @@ files:
117
118
  - lib/xcodeproj/scheme/build_action.rb
118
119
  - lib/xcodeproj/scheme/buildable_product_runnable.rb
119
120
  - lib/xcodeproj/scheme/buildable_reference.rb
121
+ - lib/xcodeproj/scheme/command_line_arguments.rb
120
122
  - lib/xcodeproj/scheme/environment_variables.rb
121
123
  - lib/xcodeproj/scheme/launch_action.rb
122
124
  - lib/xcodeproj/scheme/macro_expansion.rb