As of version 1.1.0, the BMLTiOSLib is now available as a CocoaPod. CocoaPods is a package manager for Mac OS/iOS development. It’s chiefly used for code libraries and snippets. People upload their libraries as compilable projects, and CocoaPods takes care of making sure that they will fit into your project.
If you are not familiar with CocoaPods, or you don’t want to work with CocoaPods, then you can still obtain the BMLTiOSLib directly from its new source code repo location, and you could add it as a Git submodule to your project.
The new structure is different from the original structure, as CocoaPods likes things just so.
We’ll use the demo app that we use later on in this documentation to demonstrate loading the BMLTiOSLib pod. Before doing this, you should install CocoaPods on your machine. It’s very simple, and the CocoaPods Home Page has installation instructions.
CocoaPods works by you writing a small Ruby file, and placing it in the same directory as your project file.
The one we use for the sample project looks like this:
platform:ios, '9.0' target 'DemoSimpleBMLTiOSLibClient' do use_frameworks! pod 'BMLTiOSLib', '~> 1.1.0' end
That is placed in the same directory as the Xcode project file:
You then open Terminal, and cd (Change Directory) to the directory that has the Podfile (and Xcode project).
Once there, you simply type:
$ pod update
$ pod install
You will get output that looks something like this:
Update all pods Updating local specs repositories $ /usr/bin/git -C /Users/<USER ID>/.cocoapods/repos/master fetch origin --progress $ /usr/bin/git -C /Users/<USER ID>/.cocoapods/repos/master rev-parse --abbrev-ref HEAD master $ /usr/bin/git -C /Users/<USER ID>/.cocoapods/repos/master reset --hard origin/master HEAD is now at fee9e76dc76 [Add] MAGNSAttributedStringFormat 0.2.0 Analyzing dependencies Downloading dependencies Installing BMLTiOSLib (1.1.0) Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `DemoSimpleBMLTiOSLibClient.xcworkspace` for this project from now on. Sending stats Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Now, when you look at the project, you will see a whole bunch of new files and directories:
Open the new workspace:
This will now have your project, with the new BMLTiOSLib embedded into it.
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.