Reputation: 5111
I have a library (lib.a
) and a header file (lib1.h
). The problem is the library is too big and only a relatively small subset of users need it.
ld: library not found for -llib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Would it be possible to guard against usage of the library not existing inside the Xcode project? I found the following, but I'm not sure if it's sufficient (assuming I can get the project to build without the lib):
if ([MyLibABC class]) { ... } else { NSLog(@"Add Lib.a"); }
Side note:
In Java I would use reflection to call methods implemented in the library (lib.jar
) and if the library is not present I would catch the ClassNotFoundException and show an error message or something (lib.jar missing, please consult the documentation).
I'm targeting >= iOS5.
Upvotes: 2
Views: 153
Reputation: 726849
Unlike desktop operating systems which support dynamic libraries, iOS supports only static libraries. The only way around this would be building two targets - one that uses the library, and the other one that does not.
You can build both targets from the same set of sources by using conditional compilation. In the version that conditionally compiles out the references to the "big library" there would be no references to it, so the linker would not complain about missing references.
Upvotes: 2