views:

800

answers:

1

I'm getting this error

Undefined symbols:
".objc_class_name_MyClass", referenced from:
  literal-pointer@__OBJC@__cls_refs@MyClass in infoViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

When referencing the static method below:

[MyClass ClickComment:self.navigationController];

MyClass is defined in a static library that I'm referencing in my app project. When I start typing "[MyClass "..., I get message hints. The app project knows MyClass exist and which methods are defined on it. Yet, I get the above error. Commenting out this call allows the project to build without error.

In the static library, I have a .h file that references all of the library's .h files. This way, the app project needs to reference only one .h file from the static library. The static library project also has an app. I use it to test the static library. I can do the above call fine. I usually see these types of errors when the static library has build a device/debug version and the app project has build simulator/debug. However, both builds are in sync.

I know there is a reference issue but I'm unsure how to resolve it. Any suggestions?

+2  A: 

That means that the header files are found during compilation, but the linker is not aware of the static library. Make sure your static library is listed under "Targets -> YourMainTarget > Link Binary with Libraries" in the project view.

See http://developer.apple.com/tools/XCode/XCodeprojects.html

thesamet
I've got it working now. Mainly, in the static library for MyClass, I needed to add a couple of #import statements to MyClass.m. I found that strange since all of the #import statements are in the .h file mentioned above, which is referenced by the project's PCH file, which I see in Compiled Headers of the library target. Somewhere, there is still a disconnect.
4thSpace