With iOS 8, Apple has given us the ability to create dynamic frameworks for iOS, something that has always been availible for OS X. Apart from the fact that your app and extensions can share the same code, Apple is encouraging developers to share code between iOS and OS X. Apple’s describes an example of how to do so in its WWDC 2014 Session 223 video. The problem with the described steps is that it will build two separate targets, which normally wouldn’t be a big deal, except for the following inconveniences:

#if os(iOS)
    import MyFramework
#else
    import MyFrameworkOSX
#endif

Because I found using compiler directives clumsy, through a lot of trial and error I discovered how to make a dynamic framework compile for iOS and OS X, as well as have a single universal test unit bundle. I mainly developed this process for NetworkObjects, but since then I’ve submitted merge requests for frameworks I use like ExSwift and CocoaLumberjack.

###1. Change the project’s valid architectures and supported platforms.

This should change your framework’s and test unit’s valid architectures and supported platforms as well. If not, then manually change them to inherit from the project’s build settings.

Step One

###2. Change the search paths for the Unit Test bundle

Step Two

As long as your framework’s code and dependencies (like Foundation & CoreData) will run on both iOS and OS X, this process can be applied to any framework written in Objective-C or Swift. If you have any questions, you can contact me on Gitter.