Post

Replies

Boosts

Views

Activity

How do I run AppleScript Safely inside my Swift app?
Hey there! I have a Swift app using SwiftUI, and I want to run some AppleScript Safely inside it. Here is my current code: func example() { var script = NSAppleScript(source: """ tell application "Music" play repeat with vlm from 0 to 100 by 1 set the sound volume to vlm delay \(fadetime / 100) end repeat end tell """) DispatchQueue.global(qos: .background).async { let success = script?.compileAndReturnError(nil) assert(success != nil) print(success) } } However, it does not do anything. I have tried using process, however, that simply errors out in -600 "The application is not running." Is there something I am missing here? Thank you!
3
1
1.6k
Jun ’23