-1

I am new to Mac OS X apps programming, i have created a Command line tool in xcode using swift 2.

That Command tool actually opens one other installed app (basically just few bash commands), but problem is, when i run "exec - product of script" by navigating to build, it makes a white terminal window which remains open but do opens external app, even if i close my external app, that terminal window remained open.

So i don't want that terminal window to even show. So how to make terminal/product of script invisible.

I searched a lot, but maybe not searching correctly, i tried searching " Console app on Mac", found less results than expected.

Please help

Thanks, Mac 10.10.5

Arsalan Saleem
  • 321
  • 2
  • 6
  • 21

1 Answers1

1

You can't. Command line programs require a standard in and standard out so when you invoke them via Finder the system provides a terminal session for them to run in.

You'll need to repackage your code as an Agent or something.

l00phole
  • 622
  • 3
  • 8
  • As an agent or something ?? Can u send me few links to get started. Thanks – Arsalan Saleem Oct 18 '15 at 09:32
  • 1
    I think you want something like [this](https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/10000172i-SW7-BCIEDDBJ). – l00phole Oct 18 '15 at 09:33
  • Thanks alot, also i was wondering, if that terminal can exit itself after executing that would also do the job, i am lookine into the link you provided, but if exiting terminal is possible, than it could save us recoding all stuff. Thanks a lot – Arsalan Saleem Oct 18 '15 at 09:37
  • I would have expected the terminal to terminate when the command line program exits. Does it not do that? – l00phole Oct 18 '15 at 09:38
  • No it doesn't, after executing it shows process completed and stucks, i tried putting exit(0) in swift script too. Should i post a screenshot ? – Arsalan Saleem Oct 18 '15 at 09:42
  • 1
    What about if you create a script to call your program: `#!/bin/sh exec ./program` (that's two lines), and click on that instead? – l00phole Oct 18 '15 at 09:44
  • How will we compile and run this script ?? I have one question: this script will run the swift product right ? – Arsalan Saleem Oct 18 '15 at 09:50
  • You use a text editor then set its execute-bit from the command line using `chmod 0755 myscript.sh`. Yes it will a Swift-implemented command line utility. – l00phole Oct 18 '15 at 10:39