Skip to content

codingiran/SystemExtensionKit

Repository files navigation


logo

Concurrency Wrapper for SystemExtension API


SwiftPM Compatible Cocoapods Compatible macOS Versions Supported MIT License


SystemExtensionKit

macOS platform utils for SystemExtension

Install

SwiftPM

https://github.com/codingiran/SystemExtensionKit.git

Cocoapods

pod 'SystemExtensionKit'

Examples

// Import
#if canImport(SystemExtensionKit)
import SystemExtensionKit
#endif

...

// Check SystemExtension status
if #available(macOS 12.0, *) {
    let enable = await SystemExtension.checkSystemExtensionEnableStatus()
    if enable {
        debugPrint("Enabled SystemExtension already exist")
    } else {
        debugPrint("SystemExtension is not enabled")
    }
}

// Active SystemExtension
do {
    try await SystemExtension.activeSystemExtension()
} catch {
    // Handle error
    debugPrint(error.localizedDescription)
}

// Delegate Method
SystemExtension.delegate = self

// MARK: - SystemExtensionDelegate

func systemExtensionKit(_ systemExtension: SystemExtensionKit, requestResult: SystemExtensionKit.RequestResult) {
    switch requestResult {
    case .completed(let request):
        debugPrint("SystemExtension: \(request.identifier) did finish request, user authorized")
    case .willCompleteAfterReboot(let request):
        debugPrint("SystemExtension: \(request.identifier) did finish request, but need user reboot mac")
    case .failed(let request, let error):
        debugPrint("SystemExtension: \(request.identifier) request failed: \(error.localizedDescription)")
    case .needsUserApproval(let request):
        debugPrint("SystemExtension: \(request.identifier) requires user approval")
    case .replacingExtension(let request, let existingVersion, let extensionVersion):
        debugPrint("SystemExtension replacing extension \(request.identifier) version \(existingVersion) with version \(extensionVersion)")
    }
}

About

macOS platform utils for SystemExtension

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages