MCxSystemExecOsax
provides a set of Swift wrappers around the Open Scripting Architecture eXtensions (OSAX). A general run unix script is also included.
Background ▴
Apple provides a set of common user interactions (e.g. dialogs and alerts) in the Open Scripting Architecture eXtensions (OSAX). Swift can call OSAX routines using Process()
with the executableURL
set to "/usr/bin/osascript".
let process = Process()
let url: URL = URL(fileURLWithPath: "/usr/bin/osascript") // :NOTE: future deprecated
//let url: URL = URL(filePath: "/usr/bin/osascript") // :NOTE: future
process.executableURL = url
process.arguments = args // Applescript
// ... more code here ...
It would be really interesting if a crossplatform user interaction library similar to OSAX existed. For example, such a library could likely be implemented with Swift + Gnome Toolkit (GTK+).
Resources ▴
StackOverflow: How to present a window from an OSX Swift command line tool or shebang script file? ⇗