Q:

Run custom shell script added to macOS application

How can I run my own shell script?
I know I can run system's or user's scripts using NSTask and NSPipe.
But how can I run my own script, that was added to target?

A:

Ok, when I've added .sh file to application target it had appeared it Resources folder in build. So you can run your own script like this.
This will work only for non sandboxed applications.
var output: [String] = []
var error: [String] = []

let task = Process()
var scriptPath = Bundle.main.bundlePath
scriptPath.append("/Contents/Resources/YourScript.sh")
task.launchPath = "/bin/sh"
task.arguments = [scriptPath]

let outpipe = Pipe()
task.standardOutput = outpipe
let errpipe = Pipe()
task.standardError = errpipe

task.launch()

