Can we create a custom framework using Swift package Manager?

Hi Everyone,
Can I create a custom framework using Swift Package Manager?, I don't want to share my code, I want create an SDK and share it for others to use?. Is it possible to create one? If so, can you please guild me through?

2 Likes

Do you want to make an Xcode Framework? If so, the package manager doesn't build frameworks like that directly. You will will want to use the command: swift package generate-xcodeproj and customize the generated YourProjectName.xcodeproj. You can also supply an xcconfig file that overrides settings for Xcode though I haven't used it and don't remember its name...

You can specify that a product should be type: .dynamic. Then you will get a .dylib when you build it. swift build --show-bin-path --configuration release will tell you where to find the resulting library.

Thank you so much @Braden_Scothern and @SDGGiesbrecht, Let me explain what I want clearly, I have a static library which is .a file, built using cpp and I have one swift file and obj-c files, I want to wrap these files as a single framework file. I'm sharing the .framework file. but my client want to integrate this with SPM. How can I do it? I don't want to share my code. As am new to SPM, please explain in details.

Ah closed source, that isn’t possible at the moment with SwiftPM. You will need a xcode project and likely want to give them a xcframework.

I would use the generate-xcodeproj sub command. Then edit it to build as an xcframework. Check out this WWDC session to learn how to make a xcframework: https://developer.apple.com/videos/play/wwdc2019/416/

Thank you very much @Braden_Scothern.

Terms of Service

Privacy Policy

Cookie Policy