forked from inket/update_xcode_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxcode_unsigner.rb
87 lines (65 loc) · 2.25 KB
/
xcode_unsigner.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require_relative 'xcode'
class XcodeUnsigner
extend CLI
def self.unsign_xcode
process 'Looking for Xcode...'
xcodes = Xcode.find_xcodes
.select { |xcode| xcode.version.to_f >= 8 }
.select(&:signed?)
separator
if xcodes.empty?
error "Didn't find any signed Xcode 8+ on your system."
return
end
notice
separator
selection = Ask.list "Choose which Xcode you would like to unsign (use arrows)", xcodes
return unless selection
xcode = xcodes[selection]
unsign_xcodebuild = Ask.confirm "Unsign xcodebuild too?"
separator
process 'Unsigning...'
if xcode.unsign_binary! &&
(!unsign_xcodebuild || (unsign_xcodebuild && xcode.unsign_xcodebuild!))
success 'Finished! 🎉'
else
error "Could not unsign #{xcode.path}\n"\
'Create an issue on https://github.com/inket/update_xcode_plugins/issues'
end
end
def self.restore_xcode
process 'Looking for Xcode...'
xcodes = Xcode.find_xcodes
.select { |xcode| xcode.version.to_f >= 8 }
.select(&:restorable?)
separator
if xcodes.empty?
error "Didn't find any Xcode 8+ that can be restored on your system."
return
end
selection = Ask.list "Choose which Xcode you would like to restore (use arrows)", xcodes
return unless selection
xcode = xcodes[selection]
separator
process 'Restoring...'
success = true
if xcode.binary_restorable? && !xcode.restore_binary!
error "Could not restore binary for #{xcode.path}"
success = false
end
if xcode.xcodebuild_restorable? && !xcode.restore_xcodebuild!
error "Could not restore xcodebuild for #{xcode.path}"
success = false
end
success 'Finished! 🎉' if success
end
def self.notice
puts [
'Unsigning Xcode will make it skip library validation allowing it to load plugins.'.colorize(:yellow),
'However, an unsigned Xcode presents security risks, '\
'and will be untrusted by both Apple and your system.'.colorize(:red),
"This tool will create a backup and allow you to restore Xcode's signature by running\n",
'$ update_xcode_plugins --restore'.colorize(:light_blue)
]
end
end