Cross platform Framework for iOS, watchOS, tvOS, macOS and server/linux

As a Framework developer, I've built a utility that I'd like to have it distributed publicly as well as for my apps across the platforms both on the apps and server end.


I've noticed from XCode -> New -> Project that each OS has it's own Framework project type under "Framework & Library". for instance


iOS -> Cocoa Touch Framework

watchOS -> Watch Framework

tvOS -> TV Framework

macOS -> Cocoa Framework


#1 Same applies for Static Library, and I'm confused if I should go Static Library route or the Framework route?


#2 An option, Create a separate project for each plaform while reusing for the same source code and publish to github for download and inclusion into XCodeworkspace.


#3 It became even more challenging to have it distributed via SPM for server-side applications in Swift because the folder structure gets different.


I'm looking for a solution that can work from distribution and portability point of view. The library or the framework code is very neutral, device agnostic and can run on any platform. How can I distribute it for all these fronts from a single github repo?

Replies

It is not difficult to have a single project with multiple, cross-platform targets. Do you want to have a universal framework that includes binaries for all of those platforms? I have seen people attempt it, but I would recommend it. It is a lot of extra work and risk on your part to spare people a 10 second decision on which link to click on.

"Yes I want to have a universal framework. I didn't get you on "10 second decision on which link to click on."


I'd like to see an example for your recommendation.


Second is it the .xcodeproj file that makes the difference between if it's a tvOS framework or watchOS framework?