Lightweight code sharing

With Swift, I am finding that I am frequently creating general-purpose code that I want to share between different projects. Swift code seems to be intrinically more reusable.


Sometimes this is a single file (for instance a bunch of vector math code.) Sometimes it is a small collection of files which make a bundle of functionality.

The default response to the sharing problem is "create a framework"


But turning these into a framework or static library seems like overkill. There quite a lot of cost involved. And the complexity goes up.

I have wasted quite a lot of time, trying to framwork-ise a custom view, only to discover that interface builder didn't seem to want to serialise it.


One solution would be to simply drag files into my project one at a time - to be compiled within the main module.

Is there a slightly cleaner solution?

Replies

You could perhaps just share folders with common code between projects?

So the shared code exists in one place on disk, and then several projects have references to that shared code.

I used to do this in objective c projects some years ago, and I guess it still works.