Group Group Group Group Group Group Group Group Group Forums

Command Line Programs on macOS Tutorial

Discover how easy it is to get started making your own terminal-based apps with this command line programs on macOS tutorial.

This is a companion discussion topic for the original entry at

Hi. I really wanted to thank you for writing this tutorial. I think we forget that creating command line applications is an option and it can be a really great way to do a quick and dirty application without having to worry about auto layout and interface builder.

@redqueencoder Thanks, i think command line applications have some other benefits too. You can chain several command line tools to get a result one single tool wouldn’t achieve and it can make it easier to create a platform independent application. Just write the tool platform independent and add a platform specific GUI application around it.

Hi! Thanks for your tutorial its great!
Here is small error in example for current swift version:

func getOption(- option: String) -> (option:OptionType, value: String) {
  return (OptionType(value: option), option)

it should be:

func getOption(_ option: String) -> (option:OptionType, value: String) {
  return (OptionType(value: option), option)

Superb. There’s just one thing I’ve been dying to know: how do you tell Xcode where to put the executable and what to call it instead of the ridiculous cryptic files in ~/Library/Developer/Xcode/DerivedData/?

Hi, you can change the location under Xcode->Preferences->Locations->Derived Data and maybe Advanced.
If you want to deploy/publish your Application you should use the Menu Product->Archive and after the archive was created you can export your Application inside the Organizer window Export->Save Built Products. This will put your Application inside a folder of your choice.

I have a project that uses Packages.swift and I have been compiling it with swift build command using Xcode as my editor. However, I don’t get any auto-completion because it’s not in an Xcode project.

Is it possible to do both? It would be really handy to have auto-completion for the packages I am specifying in Packages.swift.

Thanks in advance.

Under swift in Xcode 8 you can generate an Xcode project with swift package generate-xcodeproj
Then open that project with Xcode

1 Like

Amazing, thanks! That worked.

Have been using CLion which is great, but my 30 day trial is about to run out and I don’t really want to pay for it just for a personal side project.

Is it possible to use XCTest with Command Line Programs?
It seems possible, but when I’ve tried, I haven’t been able to make it work.