How do you create a "Release" build of a framework?

So, I wrote a framework in Swift 3. I've used it successfully as an embedded framework in my projects and will continue to do so. What I'd also like to do is build a "Release" version and keep it in my /Library/Frameworks folder so that I can use the import command to import it into future test projects (for internal use only.) How is this done?


I've played around with the Deployment setting of my framework project (such as the follwing settings: Installation Directory, Skip Install, Deployment Location, etc.) which, I'm assuming with the proper settings, would build my framework and place a release version into the /Library/Frameworks folder, ready for use. But I can't seem to get it working that way.


I have tried "Build for Profiling" which creates a Release build and then manually copying the built product into the aforementioned folder. But issuing an import MyFramework statement in a new Xcode project doesn't work as the framework cannot be found. There are a handful of other 3rd party frameworks in that folder that also are not recognized by an import statement.


What am I missing?


ab@pr

Answered by DTS Engineer in 202794022

The best thing to do here is to make your framework into its own Xcode project, so that you can then include a reference to that Xcode project in all of your future test projects through the steps outlined in the Embedding Frameworks Tech Note. Swift 3 does not have a stable application binary interface (ABI) yet, so having a prebuilt version of the framework to use is not supported, as such a configuration will have problems unless all of the Swift code for the entire app and all frameworks is built by the same compiler.

Apart from any possible issues with the mechanics of building, you can't do this with Swift frameworks yet. Because the ABI is not yet finalized, it is not permitted to use a built Swift framework as a freestanding unit. For now, you must build the framework in the same project as the app that uses it.


This restriction should be lifted when Swift 4 comes out, sometime in 2017.

Thanks for the quick response, QuinceyMorris!


Would you happen to have a link to some reference material that explains this? Also, if this is case, how is it possible for Apple's modules to function? Foundation, AppKit, SpriteKit, etc... Aren't all these frameworks written in Swift now?

No, all Cocoa frameworks are still Obj-C modules. That means, if they contain any Swift code, they're wrapped in Obj-C at the public interface (that is, they use the Obj-C ABI which is not subject to change).


There is some information about the Swift ABI here:


github.com/apple/swift-evolution


Technically, you should be able to create an external Swift framework that works provided you only use it with clients that are compiled with the exact same version of Swift. However, I have a vague recollection that current Xcode releases prevent you from creating pure Swift frameworks easily.


For more information, I suggest you go to the mailing lists at swift.org. Someone over there should be able to give a more detailed response.

Accepted Answer

The best thing to do here is to make your framework into its own Xcode project, so that you can then include a reference to that Xcode project in all of your future test projects through the steps outlined in the Embedding Frameworks Tech Note. Swift 3 does not have a stable application binary interface (ABI) yet, so having a prebuilt version of the framework to use is not supported, as such a configuration will have problems unless all of the Swift code for the entire app and all frameworks is built by the same compiler.

Thanks! I will refer to the resources provided to learn more.

Thanks edford. I will continue to include my framework project into my text projects for now.

How do you create a "Release" build of a framework?
 
 
Q