16
votes

I needed to create a framework (which requires a static library) for a project I'm working on. I used this tutorial to create the framework, then copied the static library into the project and it worked.

But, when I dragged the framework to an iOS project, it shows a ton of errors.

`Undefined symbols for architecture i386:"_OBJC_CLASS_$_SomeClassFromTheStaticLibrary",referenced from:_OBJC_CLASS_$_AnotherClass in MyFramework`

What I think is happening is that the iOS project wants to recompile the framework and it cannot, because it can't locate the static library. All errors disappear if I add the static library to the iOS project. This is what I want to avoid.

Basically I want to have the iOS project -> Framework -> Library instead of having the library in both the project and the framework.

I have tried adding the static library as a resource in the framework, but it didn't work.

3
any solution to your problem dude ??? i am facing a similar issue here.. - A for Alpha
I did solve it, but I sort of cheated. I had access to the source code of all three projects, so I recompiled the static library as a framework. This way I had iOS Project -> Framework -> Framework and only had to import one framework. - olivaresF
no real solution yet? I even can't get rid of that problem if I include the static libraries to the iOS project... - b00tsy

3 Answers

1
votes

I doubt this is possible. When you think about what is happening you will see the problem.

  1. The framework is compiled and the static library is processed so that things like extra symbols are stripped out
  2. The app is now compiled and linked against the framework which may or may not have had the symbols that the app is requiring

I did get this to work if ONLY the framework was using the static library (logical) but I can't find a way to share the code across the framework & the app.

0
votes

If a symbol is hidden (either via Symbols Hidden by Default/GCC_SYMBOLS_PRIVATE_EXTERN being set to YES or __attribute__ ((visibility ("hidden"))) being applied to certain symbols), then that symbol will be available when statically linking the library, but not when dynamically linking the framework.

Ensure that the static library's symbols are not hidden, and you should be able to access them from your app.

-2
votes

I have followed this link to create custom framework. I have static library inside my framework and it works fine with that.

I have copied his steps in my blog for my understanding along with a script to make it universal.