Hi I'm trying to create a static library that can added to any ios project, but I can only get it to work such that if I build the library in ios3, it'll work for ios3 projects but not ios4 and vice versa.
The errors I get are:
Undefined symbols: ".objc_class_name_UIImage", referenced from: literal-pointer@_OBJC@_cls_refs@UIImage in Test3-Release.a(TestViewController.o) ".objc_class_name_NSNotificationCenter", referenced from: literal-pointer@_OBJC@_cls_refs@NSNotificationCenter in Test3-Release.a(Test.o)
So it looks like it's not finding Foundation and UIKit frameworks for the library?
Here's what I've done so far:
I have 2 projects: 1 is a library project with a library build target. The other is a Test Project that tries to use the library built in the first library.
1) Create a project with a static library target and added all of the implementation files
2) Added libraries like UIKit, Foundation, etc to the "Link Binary with Libraries folder and Set all the linked libraries to have a weak type in my library target.
3) Built the library, added it to my test proje开发者_开发技巧ct, along with my header files.
4) In my test project, I set other linker flags to -ObjC -all_load for all build configurations
When I compile it gives me a bunch of errors as if I didn't include any frameworks.
Anyone have any ideas on what I should do?
Hint (Maybe?) I also noticed that adding any frameworks to the "Link Binary with Libraries" folder in my library target doesn't seem to do anything. I added CoreLocation to that folder, but when I try to compile in my Test Project it won't compile until I add CoreLocation to my Test Project Frameworks folder.
your dependent project (that uses static library) hassn't linked Framewrok libraries.
Just add to dependent project frameworks (uikIt,Foundation, etc) all will work fine.
精彩评论