RPScreenRecorder: Recording video

Hello everyone. I am trying to make a small utility that, in the context of digital forensics, logs the desktop. The utility is to be started via shell like this : "./nemeapp start path_to_file" and be terminated in "./nemeapp stop". The code I wrote is:

import Foundation
import ReplayKit

let arguments = CommandLine.arguments

guard arguments.count == 4 else {
    print("Utilizzo: nome_script start|stop percorso_file include_audio(true|false)")
    exit(0)
}

let command = arguments[1]
let filePath = arguments[2]
let includeAudio = arguments[3] == "true"

switch command {
case "start":
    startScreenRecording(filePath: filePath, includeAudio: includeAudio)
case "stop":
    stopScreenRecording()
default:
    print("Comando non riconosciuto. Utilizzo: nome_script start|stop percorso_file include_audio(true|false)")
}

func startScreenRecording(filePath: String, includeAudio: Bool) {
    if RPScreenRecorder.shared().isAvailable {
        RPScreenRecorder.shared().startRecording(handler: { error in
            if let unwrappedError = error {
                print("Errore durante l'avvio della registrazione: \(unwrappedError.localizedDescription)")
            } else {
                print("La registrazione dello schermo è stata avviata correttamente. Il file verrà salvato in: \(filePath)")
            }
        })
    } else {
        print("La registrazione dello schermo non è disponibile.")
    }
}

func stopScreenRecording() {
    RPScreenRecorder.shared().stopRecording { previewViewController, error in
        if let unwrappedError = error {
            print("Errore durante l'arresto della registrazione: \(unwrappedError.localizedDescription)")
        } else {
            print("La registrazione dello schermo è stata interrotta correttamente.")
        }
    }
}

Unfortunately, the code returns no error message. Only when I give the stop command does it tell me that the registration never started. I can't even figure out if it is a permissions issue.

RPScreenRecorder: Recording video
 
 
Q