xcodeproj 1.3.0 → 1.3.1

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: e0c5baea015a74f760845e1088a8248cea2a4e9a
4
- data.tar.gz: f2304115edad58e7babba2267ce0155f83415552
3
+ metadata.gz: 80889f1543d932a364554166034555b0838ab081
4
+ data.tar.gz: 67b60068200d0226b81fb02441ad0a61919588b9
5
5
  SHA512:
6
- metadata.gz: 58bf0a3f1696676cea1bcd991207b57e954a6aa77a216aa35a58c4a56e86c1804189cc676d8add8c1e811710314c3cbb2f66635522c1bb25514c4515aa274284
7
- data.tar.gz: 34f5300506484186ea25e7b6720dc1c84339579adefa28f380d6c25b6db02c4a458fd232be25058a7998777da5dae22acc5a5413b46f8bc4f43e0f6260d08bba
6
+ metadata.gz: f4a9cbd8cdece69a9118f93eaebccf888448db9bd67c3af3e7fa0cc0375339ae70683d48a3db6af5c4f1df44726e13da47f9f41119bc6ef5d7483d0e64a7e852
7
+ data.tar.gz: 7f96eb1680c4ad7e70cb9318266204fb03e88f81bfda553420bef222b93ab01043a7204f47efed0e89ee3b6c6f1ff100b92b90408a85c117a5dbf01744c22358
@@ -25,7 +25,7 @@ module Xcodeproj
25
25
 
26
26
  # @return [String] The last known object version to Xcodeproj.
27
27
  #
28
- LAST_KNOWN_OBJECT_VERSION = 47
28
+ LAST_KNOWN_OBJECT_VERSION = 48
29
29
 
30
30
  # @return [String] The last known object version to Xcodeproj.
31
31
  #
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '1.3.0'.freeze unless defined? Xcodeproj::VERSION
4
+ VERSION = '1.3.1'.freeze unless defined? Xcodeproj::VERSION
5
5
  end
@@ -1,5 +1,35 @@
1
1
  module Xcodeproj
2
2
  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
+
3
33
  # Provides support for loading and serializing property list files via
4
34
  # Fiddle and CoreFoundation / Xcode.
5
35
  #
@@ -36,9 +66,12 @@ module Xcodeproj
36
66
  def write_to_path(hash, path)
37
67
  raise ThreadError, 'Can only write plists from the main thread.' unless Thread.current == Thread.main
38
68
 
39
- if DevToolsCore.load_xcode_frameworks && path.end_with?('pbxproj')
40
- ruby_hash_write_xcode(hash, path)
41
- else
69
+ path = File.expand_path(path)
70
+
71
+ should_fork = ENV['FORK_XCODE_WRITING']
72
+ success = ruby_hash_write_xcode(hash, path, should_fork)
73
+
74
+ unless success
42
75
  CoreFoundation.RubyHashPropertyListWrite(hash, path)
43
76
  fix_encoding(path)
44
77
  end
@@ -95,8 +128,31 @@ module Xcodeproj
95
128
  # @param [String] path
96
129
  # The path of the file.
97
130
  #
98
- def ruby_hash_write_xcode(hash, path)
99
- path = File.expand_path(path)
131
+ def ruby_hash_write_xcode(hash, path, should_fork)
132
+ return false unless path.end_with?('pbxproj')
133
+ if should_fork
134
+ require 'open3'
135
+ _output, status = Open3.capture2e(Gem.ruby, '-e', <<-RUBY, path, :stdin_data => Marshal.dump(hash))
136
+ $LOAD_PATH.replace #{$LOAD_PATH}
137
+ path = ARGV.first
138
+ hash = Marshal.load(STDIN)
139
+ require "xcodeproj"
140
+ require "xcodeproj/plist/ffi"
141
+ ffi = Xcodeproj::Plist::FFI
142
+ success = ffi::DevToolsCore.load_xcode_frameworks && ffi.send(:ruby_hash_write_devtoolscore, hash, path)
143
+ exit(success ? 0 : 1)
144
+ RUBY
145
+
146
+ status.success?
147
+ else
148
+ monkey_patch_chdir
149
+ success = DevToolsCore.load_xcode_frameworks && ruby_hash_write_devtoolscore(hash, path)
150
+
151
+ success
152
+ end
153
+ end
154
+
155
+ def ruby_hash_write_devtoolscore(hash, path)
100
156
  success = true
101
157
 
102
158
  begin
@@ -111,7 +167,11 @@ module Xcodeproj
111
167
  success = false
112
168
  end
113
169
 
114
- CoreFoundation.RubyHashPropertyListWrite(hash, path) unless success
170
+ success
171
+ end
172
+
173
+ def monkey_patch_chdir
174
+ Dir.send(:include, Extensions::Dir)
115
175
  end
116
176
  end
117
177
  end
@@ -5,14 +5,11 @@ module Xcodeproj
5
5
  module FFI
6
6
  module DevToolsCore
7
7
  def self.silence_stderr
8
- begin
9
- orig_stderr = $stderr.clone
10
- $stderr.reopen File.new('/dev/null', 'w')
11
- retval = yield
12
- ensure
13
- $stderr.reopen orig_stderr
14
- end
15
- retval
8
+ orig_stderr = $stderr.clone
9
+ $stderr.reopen File.new('/dev/null', 'w')
10
+ yield
11
+ ensure
12
+ $stderr.reopen orig_stderr
16
13
  end
17
14
 
18
15
  # rubocop:disable Style/MethodName
@@ -216,6 +216,7 @@ module Xcodeproj
216
216
  if object_version.to_i > Constants::LAST_KNOWN_OBJECT_VERSION
217
217
  raise '[Xcodeproj] Unknown object version.'
218
218
  end
219
+ root_object.product_ref_group = root_object.main_group['Products'] || root_object.main_group.new_group('Products')
219
220
  end
220
221
 
221
222
  public
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.0
4
+ version: 1.3.1
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-02 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport