-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathXcode.swift
More file actions
42 lines (32 loc) · 984 Bytes
/
Xcode.swift
File metadata and controls
42 lines (32 loc) · 984 Bytes
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
import Foundation
enum XcodeError: String, Error {
case XcodeAlreadyGreat = "Xcode is already great!"
}
struct Xcode {
let url: URL
var great: Bool {
let unsigner = XcodeUnsigner(xcode: self)
return unsigner.isUnsigned
}
init(url: URL) {
self.url = url
}
func makeGreatAgain(YOLO: Bool = false) throws -> Xcode {
// guard !great else {
// print("Xcode has already been grated!")
// throw XcodeError.XcodeAlreadyGreat
// }
let newXcode = YOLO ? self : try copy()
return try newXcode.grate()
}
private func copy() throws -> Xcode {
let copier = XcodeCopier(xcode: self)
let newURL = try copier.copyXcode()
return Xcode(url: newURL)
}
private func grate() throws -> Xcode {
let unsigner = XcodeUnsigner(xcode: self)
try unsigner.irreversiblyUnsign()
return Xcode(url: url)
}
}