Class: Xcode
Constant Summary
collapse
- DEFAULT_XCODE_PATHS =
Hardcoded paths in case mdfind is not working because Spotlight is disabled
[
"/Applications/Xcode.app"
]
- XCODE_BUNDLE_IDENTIFIER =
"com.apple.dt.Xcode"
Instance Attribute Summary collapse
Attributes inherited from Bundle
#path
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Bundle
#bundle_identifier, #defaults_read, #defaults_write, #info_path, #initialize, #version
Constructor Details
This class inherits a constructor from Bundle
Instance Attribute Details
#signed ⇒ Object
Returns the value of attribute signed.
4
5
6
|
# File 'lib/xcode.rb', line 4
def signed
@signed
end
|
Class Method Details
.find_xcodes ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/xcode.rb', line 13
def self.find_xcodes
output = `mdfind kMDItemCFBundleIdentifier = "#{XCODE_BUNDLE_IDENTIFIER}"`
paths = output.lines + DEFAULT_XCODE_PATHS
paths.map(&:strip).uniq.collect do |xcode_path|
Xcode.from_bundle(xcode_path)
end.compact.keep_if(&:valid?)
end
|
.from_bundle(path) ⇒ Object
22
23
24
25
|
# File 'lib/xcode.rb', line 22
def self.from_bundle(path)
xcode = new(path)
xcode.valid? ? xcode : nil
end
|
Instance Method Details
#binary_restorable? ⇒ Boolean
48
49
50
|
# File 'lib/xcode.rb', line 48
def binary_restorable?
File.exist?("#{binary_path}.signed")
end
|
#detailed_description ⇒ Object
84
85
86
|
# File 'lib/xcode.rb', line 84
def detailed_description
"Xcode (#{version}) [#{uuid}]: #{path}"
end
|
#restorable? ⇒ Boolean
44
45
46
|
# File 'lib/xcode.rb', line 44
def restorable?
binary_restorable? || xcodebuild_restorable?
end
|
#restore_binary! ⇒ Object
64
65
66
|
# File 'lib/xcode.rb', line 64
def restore_binary!
restore!(binary_path)
end
|
#restore_xcodebuild! ⇒ Object
68
69
70
|
# File 'lib/xcode.rb', line 68
def restore_xcodebuild!
restore!(xcodebuild_path)
end
|
#signed? ⇒ Boolean
35
36
37
38
39
40
41
42
|
# File 'lib/xcode.rb', line 35
def signed?
if signed.nil?
self.signed = `codesign -dv "#{path}" 2>/dev/null` &&
$CHILD_STATUS.exitstatus == 0
end
signed
end
|
#to_s ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/xcode.rb', line 76
def to_s
unless signed.nil?
codesign_status = signed ? ' [Signed]' : ' [Unsigned]'
end
"Xcode (#{version})#{codesign_status}: #{path}"
end
|
#unsign_binary! ⇒ Object
56
57
58
|
# File 'lib/xcode.rb', line 56
def unsign_binary!
unsign!(binary_path)
end
|
#unsign_xcodebuild! ⇒ Object
60
61
62
|
# File 'lib/xcode.rb', line 60
def unsign_xcodebuild!
unsign!(xcodebuild_path)
end
|
#uuid ⇒ Object
72
73
74
|
# File 'lib/xcode.rb', line 72
def uuid
defaults_read('DVTPlugInCompatibilityUUID')
end
|
#valid? ⇒ Boolean
27
28
29
30
31
32
33
|
# File 'lib/xcode.rb', line 27
def valid?
is_app = path.end_with?('.app')
has_info = File.exist?(info_path)
return false unless is_app && has_info
bundle_identifier == XCODE_BUNDLE_IDENTIFIER
end
|
#xcodebuild_restorable? ⇒ Boolean
52
53
54
|
# File 'lib/xcode.rb', line 52
def xcodebuild_restorable?
File.exist?("#{xcodebuild_path}.signed")
end
|