Stephan
Stephan

Reputation: 7388

Creating a distributable framework for iOS Applications

I am currently building a library which should be used internally in a few iOS projects but should also be distributed to customers accessing our services with the library. The Library itself consists purely of C++ code and I am basically able to create Apps with it on iOS which work fine. My problem is creating a single, easily distributable file that can be given out to customers which can easily install them, use the provided headers and don't need to have the headaches that I am currently facing when it comes to linking.

Our code depends on two other projects, namely boost and websocketpp. For boost there is the script on github which I took to generate a framework. For websocketpp, I imported it into XCode and used the scripts from this github project to build a framework. I added both frameworks to my (potential) framework as dependencies and used the same script to build one.

I have an app using my library as a sub-project working fine. Even including the framework into the project and running it on a device works fine. So far so good.

However, trying to create an archive of the App project lead to several questions and headaches.

  1. My library did not seem to contain the code for all architectures. So I tried to archive the Framework projects, which after small modifications in the build scripts to use different locations to search for headers worked fine.

  2. It does not seem to contain all binary code or references to local files (i.e. my specific location of boost). I gathered that from Linker errors that I still get that tell me that some boost calls could not be satisfied.

The second issue made me think that I am must be doing something fundamentally wrong and my intuition tells me that it can't be that difficult and "hackish" to create frameworks or libraries for others for iOS development.

As you probably have found out by now, I am not very experienced when it comes to iOS and I am wondering if I am missing something fundamentally. So, I am sure that this question is rather broad, so some more concrete questsions:

  1. Is there a(nother) way to generate some kind of distributable (preferably a framework) which contains: my public headers, my binary code compiled for all platforms supported for iOS development, the binary code of dependencies?
    • Is the only way to do that by adding some handwritten scripts to the build process?
    • I have the feeling that the information I found is quite outdated since it's older than a year and mostly refers to Xcode 4.2 or 4.3 -- so has there anything changed in this regard recently?
  2. For example one error I get is:

    File is universal (2 slices) but does not contain a(n) armv7s slice: <file>
    

    The <file> slice is the path to the file in the framework in the Products folder of a different XCode workspace (the library was build in a different workspace then the app). I dropped the framework folder into the project for this test from a completely different location.

    • What is going on here?
    • Why does it keep referencing to some internal XCode directory?
    • How do I properly export it?
  3. Since I guess my setup is probably skrewed up and weird from all the different things I tried up to now: How does this setup look like in a ideal situation?
  4. Yes, there are some questions regarding this on SO already, however, either I don't see or don't understand in those replies:
    • ...how to handle depencies of my code to other third-party code properly.
    • ...how to generate a distributable file.

Upvotes: 1

Views: 417

Answers (1)

Raymond Law
Raymond Law

Reputation: 1188

Have you checked your project build phase under Compile Sources and Copy Files to see if you are including your framework source files in your build?

You may also try the C/C++ Library template under OSX -> Framework & Library.

Finally, there's also kstenerud’s iOS Universal Framework, which I found very useful. I wrote a few articles in my blog on using it.

Upvotes: 1

Related Questions