I am a beginner in SwiftUI. My task to capture the image of the whole screen using SwiftUI includes other apps and title bar. I am unable to show the permission dialog of screen recording and capturing the image of the screen. I have implemented the solution below but did not get success.
func screenshotWindowAndSuccess() -> Bool {
let task = Process()
task.launchPath = "/usr/sbin/screencapture"
task.arguments = ["-cm"]
task.launch()
task.waitUntilExit()
let status = task.terminationStatus
return status == 0
}
Please help me to get out of this task. Thank you in advance!