Sometimes solutions are so simple and yet it is so hard to find the right information that points towards them. So in the „Short Note“ posts I will share information about different topics that will hopefully make your search less time consuming.
Today: How to embed a private framework into your OS X App bundle, so that you can distribute your App as one single package.
So if your application relies on a framework but you want to keep distribution as simple as possible and don’t want to clutter any OS X system with tons of frameworks that are not used by several applications, simply include them into your app bundle. Back in the day it was cumbersome to perform the setup in Xcode for this. So a lot of information on the internet refer to the involved procedure. Even Apple’s documentation is no exception (Installing Your Framework). But fortunately at least with Xcode 7 (I am currently using 7.3 Beta 2) it is much easier.
All you have to do is to head over to your project settings‘ General tab and find the Embedded Binaries section. It should be right above the Linked Frameworks and Libraries section where you usually make frameworks available for your project. Click the plus sign and add the framework to the list. You“ll notice that the framework also appeared inside the Linked Frameworks and Libraries section. So if you have the framework listed twice there, simple remove the upper of the two entries. Now you are good to go.
XCode will automatically set the installation path of the framework to @executable_path/../Frameworks This tells the app where to look for the framework at runtime. You can check this at the Build Settings tab at the Linking section.
Now you can archive and export your app and it should run without any problems outside of Xcode.