Creating a static library that contains another static library

Hey there,


I have two private frameworks with control over the source code.


The first one, I'll call it "first.framework" for reference, is depended on ImageIO.framework , Security.framework and a few others.

The library is build for armv7 arm64 armv7s i386.


The other framework, "second.framework, needs to use first.framework functionality.

Is there a way to include "first.framework" inside "second.framework" so that the end user will only need to import "second.framework"?

Building "second.framework" works fine but when I try to build the app that uses "second.framework" I'm getting this error:


Undefined symbols for architecture x86_64:

"_OBJC_CLASS_$_FirstStaticView", referenced from:

objc-class-ref in second_SDK(SomeViewController.o)

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


I've made sure "Architectures" and "Valid Architectures" are all supporting armv7 arm64 armv7s i386.


*Both Frameworks works if I I use them separately.


Thanks

Replies

Have you added firstFramework.a in "Linked Frameworks and Libraries" in your main app (General)? (Don't know if you can do it from within sndFramework).


I've also added a library in "Build Phases"/"Link binary with Libraries".


I had some problems at start, but now it works. Don't know if I had to do it in both places.


EDIT:
When I think a bit more, I think my problem was that it did not build from command line (xcodebuild), but it built from within xcode. Anyhow, hope it helps.

My goal is that the end user will only need to import "second.framework". He shouldn't be aware of "first.framework" at all.

Ok. Then I guess I can't help you.

Your terminology is a bit off here. A framework is necessarily a dynamic library. A static libary is just a container of object files that needs to be linked into an app or framework. I'm guessing that by "static library" you really mean private framework — that is, a framework that's packaged inside the client app's bundle, rather than being somewhere external in the eventual user's file system.


In that case, the question is what you're really trying to do:


— If you're in control of the source code of both frameworks, then your best option is to create a single framework that includes everything from both of the individual ones.


— If the "first" framework is an open source project (or something written by someone else, but the source code — or an actual static library — is available) you should compile the source (if necessary) and link the object files into your "second framework".


— If you're trying to hide the fact that you're distributing a 3rd party framework you don't control, then you probably shouldn't do that at all. 🙂


Otherwise, your best choice is to give both frameworks to client apps. It's not onerous to add 2 frameworks to a project instead of 1, especially in recent versions of Xcode.

Thanks for your reply. I've edited the question to make things a bit clearer.

And yes, I control the source code of both frameworks and both are developed by me.

How fix the problem which the end user will only need to import "second.framework".Can you tell me?