views:

29

answers:

1

Hi,

I have some problems with creating static libraries.

Let say I have the static library A which I created and I included that to static library B with the relevant header files. I need to create a static library C which will be my final library and it it should include static library B which implicitly include the static library A. So I need to hide both implementation details of library A and B in the library C but it should not visible to the end user. Only an interface will be provided.

1) So let say my static library A uses some dependencies which are some libraries in the SDK. So do I need to import in my final project although I included the library C?

At the moment I am having some build issues when I tried above.

2) Can we bundle 3rd party static libraries inside our static libraries and distribute only our library?

3) Let say we are downloading some 3rd party code. Using that we are creating static libraries. Can we distribute a static library using 3rd party code. If so do we need to expose the code?

4) How does the static library acceptance in App store. Is it like the normal process? (I mean projects bundles with static libraries)

Thank you,

Regards,

Dilshan

+1  A: 

Wow. Four questions. If only I could get 4x the rep. :)

  1. Yes, you need to include the frameworks in the App's project. Linking a framework in a static library only creates references to symbols that don't exist. These need to be resolved during app link by linking in the frameworks to the final app.
  2. I take it you're thinking about selling an SDK of static lib files and header files. Yes, it is technically possible to link it all into one giant library (see ar(5) for details) and ship the library and select header files, but see answer #3.
  3. Depends on the license for the third-party library. Consult legal counsel if you have questions.
  4. Most apps have a static library linked in to the app. For example, the vast majority of free apps include AdMob or similar advertising packages, which are distributed as a static library. A static library doesn't, per se, violate any Apple submission policy, but the library can violate a policy, such as including undocumented APIs. If the static library violates a submission policy, an app that uses it will be rejected, even if the app doesn't use that feature.

Incidentally, you can't completely "hide" the interfaces of library A and B (from your example.) If you could, Apple would and it would not be possible to use undocumented APIs. All you can really do is leave them out of the headers and documentation.

John Franklin
OK thanks for your reply John. Great answer.
Dilshan