Skip to content

Commit b49780e

Browse files
committed
Release 1.1.4
1 parent 500e76e commit b49780e

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

Sources/SystemExtensionKit/SystemExtensionKit.swift

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import SystemExtensions
1212
#error("SystemExtensionKit doesn't support Swift versions below 5.5.")
1313
#endif
1414

15-
/// Current SystemExtensionKit version 1.1.3. Necessary since SPM doesn't use dynamic libraries. Plus this will be more accurate.
16-
public let version = "1.1.3"
15+
/// Current SystemExtensionKit version 1.1.4. Necessary since SPM doesn't use dynamic libraries. Plus this will be more accurate.
16+
public let version = "1.1.4"
1717

1818
public let SystemExtension = SystemExtensionKit.shared
1919

@@ -57,6 +57,49 @@ public class SystemExtensionKit: NSObject {
5757
case cancelExtension(OSSystemExtensionRequest, String, String)
5858
}
5959

60+
public enum ExtensionStatus {
61+
case unknown
62+
case notInstalled
63+
case waitingApproval(OSSystemExtensionProperties)
64+
case installed(OSSystemExtensionProperties)
65+
66+
public var isUnknown: Bool {
67+
switch self {
68+
case .unknown:
69+
return true
70+
default:
71+
return false
72+
}
73+
}
74+
75+
public var isNotInstalled: Bool {
76+
switch self {
77+
case .notInstalled:
78+
return true
79+
default:
80+
return false
81+
}
82+
}
83+
84+
public var isWaitingApproval: Bool {
85+
switch self {
86+
case .waitingApproval:
87+
return true
88+
default:
89+
return false
90+
}
91+
}
92+
93+
public var isInstalled: Bool {
94+
switch self {
95+
case .installed:
96+
return true
97+
default:
98+
return false
99+
}
100+
}
101+
}
102+
60103
public static let shared = SystemExtensionKit()
61104
override private init() {}
62105

@@ -98,12 +141,17 @@ public class SystemExtensionKit: NSObject {
98141
}
99142
}
100143

101-
@available(macOS 12.0, *)
102-
public func checkSystemExtensionEnableStatus() async -> Bool {
103-
if let property = try? await enabledSystemExtensionProperty() {
104-
return !property.isAwaitingUserApproval && !property.isUninstalling
144+
public func checkSystemExtensionStatus() async -> SystemExtensionKit.ExtensionStatus {
145+
if #available(macOS 12.0, *) {
146+
if let property = try? await enabledSystemExtensionProperty() {
147+
if property.isAwaitingUserApproval { return .waitingApproval(property) }
148+
if property.isUninstalling { return .notInstalled }
149+
return .installed(property)
150+
} else {
151+
return .notInstalled
152+
}
105153
} else {
106-
return false
154+
return .unknown
107155
}
108156
}
109157

0 commit comments

Comments
 (0)