IOS NSKeyedUnarchiver Error Using Static Libraries

I created a regular static library that I use in an iOS project. When I use NSKeyedUnarchiver to unlock data. It throws an exception when I try to use it in a library. I tried to copy the classes of my static library into my project to see if this would work, and that fixes the problem, but obviously the goal of the static library wins. I also tried several combinations of release / debugging and simulator / device and still not working.

Is NSKeyedUnarchiver really having trouble finding the classes needed to remove it?

EDIT I tracked the thrown exception and it says that it cannot unlock the JGObjectRep class, which is one of the other classes in the static library. Keep in mind that this works fine if I copy them to a project.

+4
source share
2 answers

Try adding these options to your linker flags: -ObjC -all_load

+5
source

Sorry, I do not know the features of the static libs used here, but here are some other thoughts that I remember from other platforms.

First of all, the problem is that class information is not completely accessible to the execution system, therefore, an error.

Ergo, a static lib either does not contain the necessary information, or the linker does not transmit information. In the latter case, you will be toasted if you do not find additional linker options that allow this feature. Therefore, read the linker manual to see if there are related parameters.

In the first case, you can first view the exported symbols with a tool (I believe that nm can do this) to make sure that the class name and its structure description are part of the symbols in lib. I don’t know how it should look, but maybe Google helps.

Another thought: what specific class does the main code refer to? If not, the linker may not include it in the final code, because it shows that it is used only in a static lib environment and therefore is not needed elsewhere. Therefore, try to see if declarations in the parameters of the compiler or linker command or in the source code pragmas can make this class generally known.

Good luck

+1
source

All Articles