Creating my First Static Library in Xcode04 Apr 2014
After learning to program for a couple of years and even posting some tutorials of my own of things I learned along the way, I figured it’s time that I start putting some work out there both in the app store and for developers to use.
I work primarily with Xcode and enjoy designing and creating apps for the iPhone and iPad the first of which is has been released and in the app store (I’ll blog about that later) and the second one should be in the app store by the end of this month (April 2014).
The time has now come that I share some of the work with companies and because this is for a company I did some work for, I’ve been asked to put it in to a static library. Although I’ve made use of static libraries and plenty of frameworks in my code, up till this week I hadn’t created my own work and put it in a static library.
After a bit of digging around, I came across this handy tutorial by the team at RayWenderlich.com. The tutorial covers how to create a static library and also includes a few extras such as some code and instruction on how to make the library universal so that developers can use it to both test on devices and to test in the simulator.
The main reason I opted for a static library was because of this comment on the RW site (linked above):
You’d like to share a library with a number of people, but not allow them to see your code.
With this being for business purposes, the code is required to be locked up for now.
Although I haven’t quite finished creating the static library, I have done some testing and followed the tutorial above and found its relatively easy to implement. There’s a few Xcode quirks along the way such as re-importing a newer version causing 2 sets of paths to be searched for and creating warnings. Also, you also might find you need to remove the headers from the target and add them back in to reset everything back up to avoid errors. Finally, when building the static library, remember to specify what headers you want exposing when you create the universal library. You do this in the “Copy Files” section of “Build Phases” for the target.
After a few small speed bumps, I think I’m almost there creating the library.