TECHNOLOGY / PROGRAMMING

Swift: How To Make A Package With Extensions

Or the hidden detail on how to ensure that extensions in a swift package are available in your project

synapticloop
4 min readOct 31, 2022

--

Image by Author

The Swift Package Management System is a great way to utilise code from remote repositories. When coupled with extensions to the language — there is just one hidden pitfall that needs to be overcome to allow any extensions to the language to be seen by your project/

The Package Manager

One of the nicest parts of the swift language is the package management system — which collects the package from a source code repository (in the majority of cases GitHub)

This makes your code available to everybody (think npm or maven or cocoa pods etc)

Swift Extensions

Another nice feature of the Swift language is that you are able to extend in-built structs and classes to add additional functionality — these are called ‘Extensions’

From the swift.org documentation on Extensions, they are

Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you don’t have

--

--