Eugen Dimboiu Eugen Dimboiu - 1 month ago 15
Swift Question

How to share custom swift extensions I built and find really useful

I'd like to share some really useful swift extensions that I built for my apps. I'm sure there are many developers that are looking to easily add the custom functionality to their apps. The only issue is I can't find a good way to share these extensions.

This is my first attempt to share iOS I find really useful with the world, so bare with me if my issues seem stupid.

I'm a experienced software engineer(most of my experience is web related) that started working iOS apps recently and I'm not familiar with packaging and distribution of swift extensions.

I'm currently using Carthage as a dependency manager and I know CocoaPods is more popular and maybe Swift Package Manager will be something in the near future - so I'd like to be able to publish the extensions so people using any of these package managers can easily add them to their projects.

Can anyone please point me in the right direction?

GJZ GJZ
Answer

I would recommend using a dependency manager like CocoaPods in order to make updating to newer versions of your extensions and installing them easier.

You may also want to share a link to the CocoaPods pods on your personal blog and spread the news about your libraries/extensions.

In CocoaPods you should provide the .Swift file as the installable pod, but should also provide the Xcode project for pod try functionality, where people try out your extension before embedding it into their projects.

Here is an example of a transition extension on CocoaPods (these are the files shown in GitHub):

enter image description here

As you can see, a demo project is provided, but when installing the pod, only the relevant Swift files are added to the project.

Here's where you can get started: https://guides.cocoapods.org/making/making-a-cocoapod.html

Hope that clears things up. Good luck :)