I tried the above ways but they didnt work for me.
Here is the code that worked for me.
do {
let filePath = "/Users/username/Downloads/switchUser.scpt"
let task = try NSUserAppleScriptTask(url: URL(fileURLWithPath: filePath))
task.execute()
}
catch {
print("some error")
}