update_xcode_plugins 0.3.2 → 0.4.0

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: e5ce0bbcfbf2d527792780fc1a3ae1f15c98abba
4
- data.tar.gz: 13899945ad14710cb46c46f62db1e87a9527ee51
3
+ metadata.gz: cdd300916ae49b90352b93a1a4a6cc89e841a1e4
4
+ data.tar.gz: 83895ce167a3d682a4b71d7e5fa1ce0c46651408
5
5
  SHA512:
6
- metadata.gz: cff0d8a41328ba10c57e4a6c317dd60baf3644bbbc3ea7df82abb87c8fd25fc359a1f23ee03e078124d3a24c6fd9709a696a5d182427fad5f4249c44e1ec0c5a
7
- data.tar.gz: 9ca6de1c58a65f7104973e5e8f2b8c97b826f60a284ac2cb142b726a1741b7f2ae94089aa6758dd4fe294395a3bb812249cd07ce6c4fc6097543aefef0e4bc2f
6
+ metadata.gz: 690f81863d024b3d3987eddcaa975ab136fd765c6eeba94376d15104744193b448e3326467034cf5157502f1632a9afbc0401f4ba6e5ca398f77de0ea3193ccd
7
+ data.tar.gz: 7b0df2e488c171afd8d5be1ed10c700b2e59581241b49e2901a698f1f5934c284b5ed83105c78b9c8abac0a639f638078be81fd3a2e75348aed4baa430bb93b5
data/README.md CHANGED
@@ -1,13 +1,19 @@
1
- ![](https://travis-ci.org/inket/update_xcode_plugins.svg?branch=master)
1
+ [![](https://travis-ci.org/inket/update_xcode_plugins.svg?branch=master)](https://travis-ci.org/inket/update_xcode_plugins) [![Coverage Status](https://coveralls.io/repos/github/inket/update_xcode_plugins/badge.svg?branch=master)](https://coveralls.io/github/inket/update_xcode_plugins?branch=master)
2
+
3
+ ![](https://img.shields.io/badge/xcode%207.3-supported-brightgreen.svg) ![](https://img.shields.io/badge/xcode%208.0-supported-brightgreen.svg) ![](https://img.shields.io/badge/xcode%208.1-supported-brightgreen.svg) ![](https://img.shields.io/badge/xcode%208.2-supported-brightgreen.svg)
2
4
 
3
5
  ### $ update\_xcode\_plugins
4
6
 
5
- This tool adds the missing UUIDs into the installed Xcode plug-ins so that they can be loaded by newer versions of Xcode.
7
+ This tool adds the missing UUIDs into the installed Xcode plugins so that they can be loaded by newer versions of Xcode.
6
8
 
7
9
  You can choose to run it once or install a **launch agent** that will trigger the tool every time any of your installed plugins are modified or Xcode/Xcode-beta gets updated.
8
10
 
9
11
  This tool also allows you to unsign Xcode in order to run plugins on Xcode 8 and later. For more information on why this is needed, see [alcatraz/Alcatraz#475](https://github.com/alcatraz/Alcatraz/issues/475).
10
12
 
13
+ When unsigning Xcode, you will also be prompted to unsign `xcodebuild`; Doing so will allow `xcodebuild` to load plugins and silence the library validation warnings. More info at [#8](https://github.com/inket/update_xcode_plugins/issues/8#issuecomment-247881598).
14
+
15
+ If you are having any issues, please check [common issues](#common-issues) before creating an issue.
16
+
11
17
  #### Install
12
18
 
13
19
  ```shell
@@ -16,6 +22,8 @@ $ gem install update_xcode_plugins
16
22
 
17
23
  (if using system ruby: `sudo gem install update_xcode_plugins`)
18
24
 
25
+ (if still having problems: `sudo gem install -n /usr/local/bin update_xcode_plugins` [#10](https://github.com/inket/update_xcode_plugins/issues/10))
26
+
19
27
  #### Usage
20
28
 
21
29
  In Terminal:
@@ -32,12 +40,12 @@ To use plugins on Xcode 8 and later, unsign Xcode with:
32
40
  $ update_xcode_plugins --unsign
33
41
  ```
34
42
 
35
- ![](http://i.imgur.com/3044DnB.png)
43
+ ![](http://i.imgur.com/XUco0su.png)
36
44
 
37
- If you need to unsign without creating a copy of Xcode, at your own risk, use the command:
45
+ If you need to restore Xcode, use the command:
38
46
 
39
47
  ```shell
40
- $ update_xcode_plugins --unsafe-unsign
48
+ $ update_xcode_plugins --restore
41
49
  ```
42
50
 
43
51
  ##### Other options
@@ -60,6 +68,12 @@ or to uninstall the launch agent,
60
68
  $ update_xcode_plugins --uninstall-launch-agent
61
69
  ```
62
70
 
71
+ ##### Common Issues
72
+
73
+ ###### Xcode crashes:
74
+
75
+ One or more of the plugins you are using are incompatible with your version of Xcode and are causing it to crash. The crash report will generally include the name of the responsible plugin. If unsure, start removing your plugins one by one until you find the culprit.
76
+
63
77
  #### Contact
64
78
 
65
79
  [@inket](https://github.com/inket) / [@inket](https://twitter.com/inket) on Twitter / [mahdi.jp](https://mahdi.jp)
@@ -2,23 +2,28 @@
2
2
 
3
3
  require_relative '../lib/update_xcode_plugins'
4
4
 
5
- if CLI.uninstall_launch_agent?
6
- LaunchAgent.uninstall
7
- else
8
- LaunchAgent.update_if_stale(__FILE__)
9
-
10
- if CLI.install_launch_agent?
11
- LaunchAgent.install(__FILE__)
12
- elsif CLI.unsign_xcode?
13
- XcodeUnsigner.unsign_xcode
5
+ begin
6
+ if CLI.uninstall_launch_agent?
7
+ LaunchAgent.uninstall
14
8
  else
15
- if CLI.non_interactive?
16
- # This tool is ran by launchctl whenever a plugin is added/modified,
17
- # which presents a race condition if the plugin is still in the process
18
- # of being modified. Counter that by sleeping for a few seconds.
19
- sleep 2
20
- end
9
+ LaunchAgent.update_if_stale(__FILE__)
21
10
 
22
- PluginsUpdater.update_plugins
11
+ if CLI.install_launch_agent?
12
+ LaunchAgent.install(__FILE__)
13
+ elsif CLI.unsign_xcode?
14
+ XcodeUnsigner.unsign_xcode
15
+ elsif CLI.restore_xcode?
16
+ XcodeUnsigner.restore_xcode
17
+ else
18
+ if CLI.non_interactive?
19
+ # This tool is ran by launchctl whenever a plugin is added/modified,
20
+ # which presents a race condition if the plugin is still in the process
21
+ # of being modified. Counter that by sleeping for a few seconds.
22
+ sleep 2
23
+ end
24
+
25
+ PluginsUpdater.update_plugins
26
+ end
23
27
  end
28
+ rescue Interrupt
24
29
  end
data/lib/cli.rb CHANGED
@@ -12,11 +12,11 @@ module CLI
12
12
  end
13
13
 
14
14
  def self.unsign_xcode?
15
- ARGV.include?('--unsign') || ARGV.include?('--unsafe-unsign')
15
+ ARGV.include?('--unsign')
16
16
  end
17
17
 
18
- def self.unsafe_unsign_xcode?
19
- ARGV.include?('--unsafe-unsign')
18
+ def self.restore_xcode?
19
+ ARGV.include?('--restore')
20
20
  end
21
21
 
22
22
  def self.no_colors?
@@ -31,9 +31,27 @@ module CLI
31
31
  `which codesign` && $CHILD_STATUS.exitstatus == 0
32
32
  end
33
33
 
34
+ def self.chown_if_required(path)
35
+ return yield if File.owned?(path)
36
+
37
+ puts
38
+ puts "* Changing ownership of #{path} (will be restored after)".colorize(:light_blue)
39
+
40
+ previous_owner = File.stat(path).uid
41
+ system("sudo chown $(whoami) \"#{path}\"")
42
+
43
+ raise "Could not change ownership of #{path}" unless File.owned?(path)
44
+
45
+ result = yield
46
+ system("sudo chown #{previous_owner} \"#{path}\"")
47
+ puts "* Restored ownership of #{path}".colorize(:light_blue)
48
+
49
+ result
50
+ end
51
+
34
52
  {
35
53
  title: :blue,
36
- process: :magenta,
54
+ process: :light_blue,
37
55
  warning: :yellow,
38
56
  error: :red,
39
57
  success: :green
@@ -12,7 +12,7 @@ class PluginsUpdater
12
12
  return
13
13
  else
14
14
  title 'Found:'
15
- puts xcodes.map { |s| "- #{s}" }
15
+ puts xcodes.map { |xcode| "- #{xcode.detailed_description}" }
16
16
  end
17
17
 
18
18
  separator
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class UpdateXcodePlugins
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/xcode.rb CHANGED
@@ -43,6 +43,18 @@ class Xcode < Bundle
43
43
  signed
44
44
  end
45
45
 
46
+ def restorable?
47
+ binary_restorable? || xcodebuild_restorable?
48
+ end
49
+
50
+ def binary_restorable?
51
+ File.exist?("#{binary_path}.signed")
52
+ end
53
+
54
+ def xcodebuild_restorable?
55
+ File.exist?("#{xcodebuild_path}.signed")
56
+ end
57
+
46
58
  def unsign_binary!
47
59
  unsign!(binary_path)
48
60
  end
@@ -51,16 +63,28 @@ class Xcode < Bundle
51
63
  unsign!(xcodebuild_path)
52
64
  end
53
65
 
66
+ def restore_binary!
67
+ restore!(binary_path)
68
+ end
69
+
70
+ def restore_xcodebuild!
71
+ restore!(xcodebuild_path)
72
+ end
73
+
54
74
  def uuid
55
75
  defaults_read('DVTPlugInCompatibilityUUID')
56
76
  end
57
77
 
58
78
  def to_s
59
79
  unless signed.nil?
60
- codesign_status = signed ? '[Signed]' : '[Unsigned]'
80
+ codesign_status = signed ? ' [Signed]' : ' [Unsigned]'
61
81
  end
62
82
 
63
- "Xcode (#{version}) [#{uuid}]#{codesign_status}: #{path}"
83
+ "Xcode (#{version})#{codesign_status}: #{path}"
84
+ end
85
+
86
+ def detailed_description
87
+ "Xcode (#{version}) [#{uuid}]: #{path}"
64
88
  end
65
89
 
66
90
  private
@@ -81,10 +105,25 @@ class Xcode < Bundle
81
105
 
82
106
  def unsign!(target)
83
107
  unsigned_target = "#{target}.unsigned"
108
+ signed_target = "#{target}.signed"
109
+
110
+ CLI.chown_if_required(File.dirname(target)) do
111
+ `#{unsign_path} "#{target}"` &&
112
+ $CHILD_STATUS.exitstatus == 0
113
+ File.exist?(unsigned_target) &&
114
+ FileUtils.mv(target, signed_target) &&
115
+ File.exist?(signed_target) &&
116
+ FileUtils.mv(unsigned_target, target)
117
+ end
118
+ end
84
119
 
85
- `#{unsign_path} "#{target}"` &&
86
- $CHILD_STATUS.exitstatus == 0 &&
87
- File.exist?(unsigned_target) &&
88
- FileUtils.mv(unsigned_target, target)
120
+ def restore!(target)
121
+ signed_target = "#{target}.signed"
122
+
123
+ CLI.chown_if_required(File.dirname(target)) do
124
+ File.exist?(signed_target) &&
125
+ File.exist?(target) &&
126
+ FileUtils.mv(signed_target, target)
127
+ end
89
128
  end
90
129
  end
@@ -4,13 +4,6 @@ class XcodeUnsigner
4
4
  extend CLI
5
5
 
6
6
  def self.unsign_xcode
7
- unless CLI.codesign_exists?
8
- # Not sure if codesign comes pre-installed on fresh macOS, so we'll check
9
- # Send a pull request if you think it does :)
10
- error 'The `codesign` tool could not be found on your system'
11
- return
12
- end
13
-
14
7
  process 'Looking for Xcode...'
15
8
  xcodes = Xcode.find_xcodes
16
9
  .select { |xcode| xcode.version.to_f >= 8 }
@@ -19,68 +12,76 @@ class XcodeUnsigner
19
12
  separator
20
13
 
21
14
  if xcodes.empty?
22
- error "Didn't find any Xcode 8+ installed on your system."
15
+ error "Didn't find any signed Xcode 8+ on your system."
23
16
  return
24
- else
25
- puts notice
26
- puts copy_notice unless CLI.unsafe_unsign_xcode?
27
17
  end
28
18
 
19
+ notice
29
20
  separator
30
21
 
31
- selection = Ask.list prompt, ['Cancel', xcodes].flatten
32
- return unless selection && selection != 0
22
+ selection = Ask.list "Choose which Xcode you would like to unsign (use arrows)", xcodes
23
+ return unless selection
33
24
 
34
- xcode = xcodes[selection - 1]
25
+ xcode = xcodes[selection]
35
26
 
36
27
  unsign_xcodebuild = Ask.confirm "Unsign xcodebuild too?"
37
28
 
38
- if CLI.unsafe_unsign_xcode?
39
- new_xcode = xcode
40
- else
41
- new_xcode_path = '/Applications/Xcode-unsigned.app'
42
- if Dir.exist?(new_xcode_path)
43
- error 'Xcode-unsigned.app already exists.'
44
- return
45
- end
46
-
47
- process 'Copying Xcode... (this might take a while)'
48
- FileUtils.cp_r(xcode.path, new_xcode_path)
49
- new_xcode = Xcode.new(new_xcode_path)
50
- end
29
+ separator
51
30
 
52
31
  process 'Unsigning...'
53
- if new_xcode.unsign_binary! &&
54
- (!unsign_xcodebuild || (unsign_xcodebuild && new_xcode.unsign_xcodebuild!))
32
+ if xcode.unsign_binary! &&
33
+ (!unsign_xcodebuild || (unsign_xcodebuild && xcode.unsign_xcodebuild!))
55
34
  success 'Finished! 🎉'
56
35
  else
57
- error "Could not unsign #{File.basename(new_xcode.path)}\n"\
36
+ error "Could not unsign #{xcode.path}\n"\
58
37
  'Create an issue on https://github.com/inket/update_xcode_plugins/issues'
59
38
  end
60
39
  end
61
40
 
41
+ def self.restore_xcode
42
+ process 'Looking for Xcode...'
43
+ xcodes = Xcode.find_xcodes
44
+ .select { |xcode| xcode.version.to_f >= 8 }
45
+ .select(&:restorable?)
46
+
47
+ separator
48
+
49
+ if xcodes.empty?
50
+ error "Didn't find any Xcode 8+ that can be restored on your system."
51
+ return
52
+ end
53
+
54
+ selection = Ask.list "Choose which Xcode you would like to restore (use arrows)", xcodes
55
+ return unless selection
56
+
57
+ xcode = xcodes[selection]
58
+
59
+ separator
60
+
61
+ process 'Restoring...'
62
+
63
+ success = true
64
+
65
+ if xcode.binary_restorable? && !xcode.restore_binary!
66
+ error "Could not restore binary for #{xcode.path}"
67
+ success = false
68
+ end
69
+
70
+ if xcode.xcodebuild_restorable? && !xcode.restore_xcodebuild!
71
+ error "Could not restore xcodebuild for #{xcode.path}"
72
+ success = false
73
+ end
74
+
75
+ success 'Finished! 🎉' if success
76
+ end
77
+
62
78
  def self.notice
63
- [
79
+ puts [
64
80
  'Unsigning Xcode will make it skip library validation allowing it to load plugins.'.colorize(:yellow),
65
- '',
66
81
  'However, an unsigned Xcode presents security risks, '\
67
82
  'and will be untrusted by both Apple and your system.'.colorize(:red),
68
- 'Please make sure that you have launched this version of Xcode at least '\
69
- 'once before unsigning.'.colorize(:red)
70
- ]
71
- end
72
-
73
- def self.copy_notice
74
- [
75
- 'We recommend keeping a signed version of Xcode, so this tool will:',
76
- '- Create a copy of Xcode.app called Xcode-unsigned.app (consider the disk space requirements)',
77
- '- Unsign Xcode-unsigned.app'
83
+ "This tool will create a backup and allow you to restore Xcode's signature by running\n",
84
+ '$ update_xcode_plugins --restore'.colorize(:light_blue)
78
85
  ]
79
86
  end
80
-
81
- def self.prompt
82
- "Choose which Xcode.app you would like to "\
83
- "#{CLI.unsafe_unsign_xcode? ? '' : 'copy and '}"\
84
- "unsign (use arrows)"
85
- end
86
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: update_xcode_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mahdi Bchetnia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: 1.3.6
81
81
  requirements: []
82
82
  rubyforge_project: update_xcode_plugins
83
- rubygems_version: 2.5.1
83
+ rubygems_version: 2.5.2
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Updates Xcode plug-ins to match the installed Xcode versions.