iPhone SDK linking errors with static library

我的未来我决定 提交于 2019-12-01 03:34:04
Shaggy Frog

Have you added the library as a dependency to the project? See Xcode 3.1.1 and static libraries

If you drill down into your target, does the library name appear in the "Link binary with libraries" group?

Look at the log for the compiler/linker output. Find the call to the linker. Does your library appear on the list of static libraries to link in?

Yes I solved this error .. a Big Thanks to @Shaggy Frog

Error

I was using some YouTube classes and its giving me below error

Solution

We need to add the Lib Classes to "Compiler Sources" in "Build Phases" option.

  1. Go to Project's Build Phases and click on Compiler Sources option (see below screen).

  2. Then Add the classes here

now make Project Clean and Go for Build.

Hope it helps :)

I just encountered the same linker error. I discovered through trial and error that it was because I was invoking isKindOfClass. I'm not sure why this causes the linker to barf, but hopefully this information helps out.

The class in question, OrderItem, is a child of NSManagedObject; in other words, it's an automatically-generated Core Data entity class.

Specifically, here was the linker error:

"_OBJC_CLASS_$_OrderItem", referenced from:
objc-class-ref-to-OrderItem in libmyStaticLib.a(MyTableViewController.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

And here was the offending code:

- (void)handleButtonTapWithObject:(id)object
{
    // This must be an OrderItem or else we don't want to touch it:
    if ( NO == [object isKindOfClass:[OrderItem class]] ) // <-- OFFENDING CODE
    {
        NSLog(@"Object parameter is of unexpected type.");
        return;
    }

My workaround was simply to omit the test that ensures 'object' is an OrderItem. The code is not as secure without this test, but the linker error went away. I'd be curious to know if I am going about this test wrong, and perhaps there is a better way of doing this.

ashraf

I just found if you are using xcode 4 you should drag and drop the library project, then go to your target settings, then in the summary tab in linked frameworks and libraries add your library and done.

Hope it will help someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!