Swift Package to list all windows running on the user macOS system.
This solution is App Store-compliant and does not require user actions, nor special permissions.
This is being used in production by my Desktop Pets app (which is also here on GitHub).
The package will return a mocked, empty, list of windows on iOS, support has been added to ease development of multiplatform apps.
You can use a WindowsDetector instance like any other ObservableObject, like in the state of your view:
import SwiftUI
import WindowsDetector
struct WindowsListView: View {
@StateObject var windowsDetector = WindowsDetector().started(pollInterval: 1)
var body: some View {
List(windowsDetector.userWindows) { window in
Text(window.description)
.background(window.isFrontmost ? Color.red : Color.clear)
}
}
}
Or, you can use the underlying service as you need:
import WindowsDetector
let service = WindowsDetectionService()
let windows = service.listCurrentWindows()
link |
Stars: 1 |
Last commit: 3 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics