-4

I'm trying to create executable file in swift to run main executable file with arguments i want to do it like this .sh file:

dir=$(dirname "$0")
exec "${dir}"/Main "$@"

how can i deploy such thing for iOS

Toaster
  • 11
  • 2

1 Answers1

-2

You can use NSTask:

func shell(args: String...) -> Int32 {
    let task = NSTask()
    task.launchPath = "/usr/bin/env"
    task.arguments = args
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

let appPath = dir + "Main"
shell(appPath, "arg1", "arg2")
Alexander
  • 59,041
  • 12
  • 98
  • 151
  • I can't use this on iOS, when i compile this, error occures on NSTask() – Toaster Jun 17 '16 at 13:48
  • Oh yeah, NSTask was removed from iOS. Due to app sandboxing, you can't just execute arbitrary code like this. What are you trying to achievE? – Alexander Jun 17 '16 at 13:55
  • i've signed & converted .deb file to .ipa to run on non jailbroken iphone, the app i want to run uses shell script above.. – Toaster Jun 17 '16 at 13:57
  • when app is run without that script, it can't resolve device id – Toaster Jun 17 '16 at 13:58