How to embed a private Objective-C infrastructure in an iOS application on Xcode 6 with workspaces

I wrote a small private structure that I want to share between several iOS applications.

Here is the workflow that I imagine:

  • Extract SimpleApp from the source control.
  • Pull BobFramework from source control.
  • Somehow embed BobFramework in SimpleApp using Xcode.
  • Build a project.
  • Done!

The problem is how to complete the "Embed with Xcode" step?

I cannot find step-by-step instructions on how to do this. Apple docs are an outdated lie.

All the stack overflow questions that I have found suggest that readers know the general procedure, and I cannot collect enough contextual prompts to complete the implied steps. In fact, I would say that many questions are related to the fact that Apple does not have a modern published procedure, and therefore many people follow the proposed or guessed steps.

The simplest, simplest, most complete, and most updated set of steps I've found applies mainly to Swift. The procedure for Swift is reasonable, and I would like to use it, but I use Objective-C.

I tried several experiments based on the assumption that this is a procedure, but there are so many possibilities of what may be the right procedure, that I don’t think that publishing one of my specific problems is the right approach at this time, In the end, everything I did leading to my problem may be wrong.

+2
source share
1 answer

It took me a while to figure this out, but I did it. I posted a more detailed answer to my blog with a few screenshots.

Now, to condense this answer for. I will explain an example recipe.

Starting point:

  • A workspace named SandBox2 with a project named Pen1.
  • BobLib is the name of the framework in its own project.
    • Created by file | New | Project, iOS | Framework and library | Cocoa Touch Framework.
    • In a separate project to simulate my specific situation. If you have such an opportunity, you should most likely start with a framework already part of the workspace.
    • The Newhart.h header file contains the declaration of the doThatThing method.

Purpose: The ViewController in Pen1 calls doThatThing on an instance of the Newhart class.

Steps:

  • Import Newhart.h to BobLib.h #import <BobLib/Newhart.h>
  • Designated by Newhart.h as open.
    • Select Newhart.h in the Project Navigator.
    • In the field of public utilities | File inspector | Targeted change in the membership of the Project to Public.
  • Create BobLib for both simulators and devices.
  • Click Control-click BobLib.framework and select "Show in Finder".
  • Open the Sandbox in Xcode.
  • Drag BobLib.framework from the Finder window to Pen1.
  • Project | Purpose | General | Embedded binaries, add BobLib.framework.
  • BobLib.framework should already be in Project | Purpose | General | Associated structures and libraries.
  • Run and test the application. It should be able to call doThatThing on an instance of Newhart.
  • This only works for iOS 8 or higher.
+1
source

Source: https://habr.com/ru/post/982579/


All Articles