iosobjective-cxcode6xcode-workspace

How to embed private Objective-C framework into iOS app on Xcode 6 with workspaces


I have written a small private framework that I want to share between a few iOS apps.

Here is the work flow I envision:

  1. Pull SimpleApp from source control.
  2. Pull BobFramework from source control.
  3. Somehow embed BobFramework into SimpleApp using Xcode.
  4. Build project.
  5. Done!

The problem is how do I accomplish the "embed using Xcode" step?

I cannot find step-by-step instructions on how to do this. Apple's docs are an out-of-date lie.

All the Stack Overflow questions I have found assume readers know the overall procedure, and I cannot gather enough contextual clues to fill in the implied steps. In fact, I would say a lot of questions stem from the fact there is no modern published procedure from Apple and thus a lot of people are following implied or guessed-at steps.

The most direct, simple, complete, and up-to-date set of steps I have found applies mainly to Swift. The procedure for Swift is sensible, and I wish I was using it, but I am using Objective-C.

I have tried several experiments based on what I am guessing the procedure is, but there are so many possibilities of what the correct procedure could be, that I do not think posting one of my specific problems is the proper approach at this time. After all, everything I have done leading up to my problem could be incorrect.


Solution

  • It took me a while to figure this out, but I did. I posted a more elaborate answer on my blog with several screen shots.

    Now to condense that answer down for Stack Overflow. I will explain by example recipe.

    Starting point:

    Goal: ViewController in Pen1 calls doThatThing on instance of Newhart class.

    Steps:

    1. Import Newhart.h in BobLib.h #import <BobLib/Newhart.h>
    2. Designated Newhart.h as public.
      1. Selecting Newhart.h in Project Navigator.
      2. In Utilities Area | File Inspector | Target Membership change "Project" to "Public".
    3. Build BobLib for both Simulator and Device.
    4. Control-click BobLib.framework and select Show in Finder.
    5. Open Sandbox2 in Xcode.
    6. Drag BobLib.framework from Finder window to Pen1.
    7. Project | Target | General | Embedded Binaries, add BobLib.framework.
    8. BobLib.framework should already be in Project | Target | General | Linked Frameworks and Libraries.
    9. Run and test app. It should be able to call doThatThing in Newhart instance.
    10. This only works for iOS 8 or higher.