Class: Xcode
Constant Summary
collapse
- DEFAULT_XCODE_PATHS =
Hardcoded paths in case mdfind is not working because Spotlight is disabled
[
"/Applications/Xcode.app",
"/Applications/Xcode-beta.app",
"/Applications/Xcode-unsigned.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
15
16
17
18
19
20
21
22
|
# File 'lib/xcode.rb', line 15
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
24
25
26
27
|
# File 'lib/xcode.rb', line 24
def self.from_bundle(path)
xcode = new(path)
xcode.valid? ? xcode : nil
end
|
Instance Method Details
#binary_restorable? ⇒ Boolean
50
51
52
|
# File 'lib/xcode.rb', line 50
def binary_restorable?
File.exist?("#{binary_path}.signed")
end
|
#detailed_description ⇒ Object
86
87
88
|
# File 'lib/xcode.rb', line 86
def detailed_description
"Xcode (#{version}) [#{uuid}]: #{path}"
end
|
#restorable? ⇒ Boolean
46
47
48
|
# File 'lib/xcode.rb', line 46
def restorable?
binary_restorable? || xcodebuild_restorable?
end
|
#restore_binary! ⇒ Object
66
67
68
|
# File 'lib/xcode.rb', line 66
def restore_binary!
restore!(binary_path)
end
|
#restore_xcodebuild! ⇒ Object
70
71
72
|
# File 'lib/xcode.rb', line 70
def restore_xcodebuild!
restore!(xcodebuild_path)
end
|
#signed? ⇒ Boolean
37
38
39
40
41
42
43
44
|
# File 'lib/xcode.rb', line 37
def signed?
if signed.nil?
self.signed = `codesign -dv "#{path}" 2>/dev/null` &&
$CHILD_STATUS.exitstatus == 0
end
signed
end
|
#to_s ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/xcode.rb', line 78
def to_s
unless signed.nil?
codesign_status = signed ? ' [Signed]' : ' [Unsigned]'
end
"Xcode (#{version})#{codesign_status}: #{path}"
end
|
#unsign_binary! ⇒ Object
58
59
60
|
# File 'lib/xcode.rb', line 58
def unsign_binary!
unsign!(binary_path)
end
|
#unsign_xcodebuild! ⇒ Object
62
63
64
|
# File 'lib/xcode.rb', line 62
def unsign_xcodebuild!
unsign!(xcodebuild_path)
end
|
#uuid ⇒ Object
74
75
76
|
# File 'lib/xcode.rb', line 74
def uuid
defaults_read('DVTPlugInCompatibilityUUID')
end
|
#valid? ⇒ Boolean
29
30
31
32
33
34
35
|
# File 'lib/xcode.rb', line 29
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
54
55
56
|
# File 'lib/xcode.rb', line 54
def xcodebuild_restorable?
File.exist?("#{xcodebuild_path}.signed")
end
|