Generating XCFramework through SPM command

Motivation

Since generate-xcodeproj will be deprecated, I think that would be awesome if SPM supports the archive process to compile Package.swift and generate a .xcframework product. This makes so much sense for me when we consider the distribution of binary libraries that is developed using the SPM structure (FYI that is so much simple and not confusing than using .xcproject).

Proposal

Adding a new command to SPM to build the library Package.swift using all directives that are detailed inside it and compiling a .xcframework. Something like: swift package generate-binary.

Benefits

This makes so much sense since SPM is supporting the distribution of binary libraries and it will be so much simpler for developers to keep doing their jobs. And of course, migrate their frameworks to SPM structure.

Self Case

I'm actually exploring this feature in some projects and I really missed an SPM way to do that. The best way that I found was not even creating Xcode framework project, which was missing dSyms symbols and BCSymbols, but integrating the role release process with fastlane using the create_xcframework command.

Even though, I have to use the SPM generate-xcodeproj command to have the Xcode Framework project and built it to finally get the xcframework from an SPM library.

I think that this is not a really bad experience, but it sure is something to bring to SPM compatibility.

5 Likes

While I agree that we should cover this use case, I don't think SwiftPM is the right place to do this. This should happen in Xcode, as its build system already knows how to build frameworks as well as XCFrameworks.

Hmm, I guess so. I don't know but the way that it feels like SPM supporting binary targets is just a hack over Xcode Frameworks. SPM acts just like a provider of the binary and does not really support it, you can't compile it, you can't distribute, only provide that to Xcode do what it should do.

I think that this feature can be explored to remove the direct dependency to Xcode and give the right support to binary targets, but maybe this doesn't make any sense or is out of scope.

I really loved working with SPM to create private code and distribute the library as a binary framework. If SPM could do this natively, it would be incredible.

2 Likes

I thought a lot about this and maybe the goal of this thread is not to support xcframework but to rethink the binary frameworks and how they are distributed by SPM. I don't know, somehow making a new binary distribution format that isn't the xcframework and fully supported by only SPM. :thinking:

Well, that’s proposed in the future directions of SE-0305. It’s definitely the direction I’d like to see in SwiftPM evolution as a multi-platform user.

1 Like

That's awesome. This will solve this problem with a great solution. I think now this thread is closed haha

For anybody that want to follow it, the proposal SE-0305 is actually in revision

Terms of Service

Privacy Policy

Cookie Policy