Creating a new executable

While there are many scripting languages available to create command line tools, creating binary executables has many benefits. Specially when you can write them in Swift.

These are the minimum steps to create a new command line tool and run it:

$ mkdir mycommandlinetool
$ cd mycommandlinetool
$ swift package init --type executable
$ swift run
Hello world!

To generate an Xcode project, you can run:

$ swift package generate-xcodeproj
generated: ./mycommandlinetool.xcodeproj

Running the project on Xcode

Keep this command handy, as you will need to regenerate the Xcode project when adding new dependencies to the Package.swift file.

Command Line Tools Series