I've got a trivial MacOS script:
#!/bin/sh
# OpenInSafari.sh
open /tmp/GitNAVs.html
that I try to invoke with:
let bundle = Bundle.main
if let script = bundle.url(forResource: "OpenInSafari", withExtension: "sh") {
do {
let scriptTask = try NSUserScriptTask(url: script)
scriptTask.execute(completionHandler: nil)
} catch {
print(error)
}
But I get:
Error Domain=NSCocoaErrorDomain Code=259 "The file “OpenInSafari.sh” couldn’t be opened because it isn’t in the correct format."
The *.sh file was created by Xcode and is where it's supposed to be in the bundle with read and write permissions. Any clue what's the problem?
Thanks,
Richard