Group Group Group Group Group Group Group Group Group

Swift - macOS Command line tools - how to package?

Hi everyone,
I’ve been busy writing some command line tools in Swift 4, Xcode 10.1 - with great success. I’ve included the new Utility Library etc.

Run’s all fine on my own Mac but I cannot get them to run on my non-development Mac.
Simply put - it’s the issue of the libraries not being linked into the executable. I’ve read a few pages about how to address this with a Bundle structure, but I’ve not actually been able to get it working.

Just wondering if someone has a solid tutorial that they can share. Something that shows how to set up a new command line project that will output a full Bundle with the command line tool and the required libraries / dependancies included.

I noted that the existing excellent command line tool tutorial ( doesn’t include any of this - perhaps an update to that would be helpful?

Thanks all.

Hi @drenwick,
The easiest way is to use Swift Package Manager which would help you manage dependencies, etc all from the one utility.

And yes, there is a lack of tutorials on this topic. For GUI applications, there are several apps that help create the DMG for distribution. With commandline utilities most were distributed as source that users compiled to use or via brew type tools.


Thats @jayantvarma
Not sure that using Swift Package Manager helps at all with the final output Product. I used the SPM to include the Utility library but that in itself doesn’t create the required bundle structure that is required to make the Product portable.

Will take another look as some of the examples that I didn’t have luck with before and see if I can make them work.

When adding the library files, are you linking the .dylib or the .a library file? You can check for this in the Targets > General > Linked Frameworks and Libraries.

CLI applications differ from regular MacOS apps in that they don’t have bundle resources (that folder like structure), instead they are a single binary with dynamic library stubs or the static library itself.

This topic was automatically closed after 166 days. New replies are no longer allowed.