DEV Community

Cover image for Creating Command Line Tool using swift package manager
Japneet Singh
Japneet Singh

Posted on

Creating Command Line Tool using swift package manager

Introduction to SPM

The release tool used in swift programming is a swift package manager Package Manager
The Swift Package Manager is a tool for controlling Swift code distribution. It works with the Swift build system to automate the download, compilation, and linking of dependencies.
-The Package Manager is included in Swift 3.0 and above.-

$ swift package init --type executable
Enter fullscreen mode Exit fullscreen mode

Release version to command-line-Tool

You'll want to install your command-line utility after you've finished developing it. This can be accomplished by using the release configuration while building. Within the.build/release folder, an executable will be created. We need to copy it into the /usr/local/bin folder before we can utilise it.

$ swift build --configuration release
$ cp -f .build/release/banner /usr/local/bin/banner
Enter fullscreen mode Exit fullscreen mode

Image description

Using Git Tags

Image description

git tag  -a v1.1 -m "ModernSSG version"
Enter fullscreen mode Exit fullscreen mode

User Testing

Well, I partenered with ritik bheda, he made his project in node.js. Testing with node.js is simpler and easier task. I tested the project and we didn't run into any error. It was very well communicated with other members to test project build in their language.

How to use and run my swift project

$ swift build
$ swift run
Enter fullscreen mode Exit fullscreen mode

or
Double click the ModernSSG executable file to run the project.

Image description

Top comments (0)