In order to make use of the framework as flexible as possible, we’ll just assume that you’ll add the BMLTiOSLib project itself to your own project (as an embedded project), and maybe also inside a shared workspace.
This isn’t something that you can normally do with every framework, but it is the easiest way to work with the BMLTiOSLib. You have the source, and the project, and we assume that you are being careful about your header search paths, so embedding the project shouldn’t be a huge deal.
This is not a classic static library, as it was written in Swift, and Swift won’t let you build static libraries. It’s a dynamic shared framework, which makes it rather complex to put into a shareable binary form. Doing it this way will make your life a lot easier.
The workflow we’ll discuss here will be the one we use for the NA Meeting Finder App. In fact, you can follow along, if you like. At the time of this writing, everything you see here will be in the “master” repo, but expect it to end up in the “release” repo soon.
Step One: Add the BMLTiOSLib Project To Yours As A Git Submodule
There’s a number of ways to do it (which we’ll leave to you to exercise), but the resulting file structure for us looked like this:
The highlight displays the submodule.
Since it’s a submodule, the directory needs to be located inside of our project directory.
You do need to be careful of this kind of structure if you are sloppy about how you do things like header search paths. You shouldn’t just point to the main project directory and say “recursive.” You need to be a bit more specific. Git submodules don’t allow you to embed only parts of the submodule project. You need to embed the entire project, which, in the case of the BMLTiOSLib, also includes a fairly substantial test harness application, which we will ignore. There’s quite a few files involved with the test harness app.
Step Two: Add the BMLTiOSLib Xcode Project to Your Xcode Project
The next thing we do, is actually make the new submodule Xcode project part of our own project, so we can access its products as dependencies (this ensures that we will always have a correct architecture of the library for our debugging or archiving).
In our example, we are using an Xcode Workspace, so the first thing that we did was add the BMLTiOSLib project to our workspace, which resulted in the project being located next to ours:
Then we dragged the project into our project, making sure that we didn’t include it in any targets:
This results in the project being embedded in ours:
We chose to put it into our “Frameworks” group in order to get it out of the way. We never will actually need to do anything with that reference.
Step Three: Add the BMLTiOSLib Framework Target As A Dependency in Our Project
Then we add the project library build as a dependency. We do this by selecting our project, the desired target, open the first line in Build Phases, and click on the “+” sign:
This will give us the following chooser. We choose the “BMLTiOSLib” target as our dependency (note the “Toolbox” icon):
Which results in the BMLTiOSLib target being the first dependency of our project:
This will ensure that it is always built to order for the current project purposes (like running on a simulator or a device, or being archived for release or distribution).
You may also need to add it as a linked library, like so:
Which brings up a chooser, like so:
And winds up with something that may look like this:
We can pretty much forget about it for a while, as we get to working on our own project. It will be there, and is included in your Swift files via a simple:
Now that it’s in place, let’s find out how to actually use it.