suppress instance method override linker warning framework xcode
Asked Answered
A

2

22

I have a library that started throwing a couple linker warnings under XCode 4.4. The warnings are along the lines of "ld: warning: instance method 'methodName:' in category from overrides method from class in "

The framework still work fine, and I assume the company that wrote it will correct this in the next release, but for the time being these warnings are very annoying. Is there any way to turn them off without disabling all linker warnings?

Anticlerical answered 6/8, 2012 at 13:43 Comment(3)
I think it means that the people that made the library improperly subclassed some things. Doesn't seem to break anything but the linker is a little whinny about it which is annoying since I can't fix it because it's a closed source.Anticlerical
Did you create/name a method in your class, same as another method in the other class?Ake
They aren't my classes. It's in a prebuilt library.Anticlerical
H
15

There are two options I have come up with by adding flags to "Other Linker Flags" in the Xcode build settings area:

1) Adding -Xlinker -w will suppress all linker warnings, no matter the type (this is the -w flag to ld(1)). Obviously that will quiet this particular warning, but all other ld warnings as well.

2) Adding -Xlinker -no_objc_category_merging will skip the optimization step where the linker combines all category methods into the base class during linking, which would then occur at runtime instead. Tiny bit slower on startup probably, but it would probably still be faster than method swizzling at runtime, and since it is during this step that ld(1) issues the warning, it will skip that too.

It appears that ld does not have a way to surgically suppress any individual warning the way the compiler does, although it has specialty flags for a couple of them or groups of them (none of which help with this one). Neither solution above is probably recommended for production code, but in some situations, one or the other might help.

Harping answered 13/11, 2013 at 20:22 Comment(0)
S
1

If an option for hiding that warning exists it would be under:

Project Navigator(the file list on the left )-> [Project name](the one with the blue icon) -> Build Settings -> Apple LLVM compiler 3.1 - Warnings

Also:

In Xcode, how to suppress all warnings in specific source files?

Spendable answered 4/9, 2012 at 1:35 Comment(4)
Thanks for this. There's no warnings in the compiler sections that are specific to libraries or the particular warnings I'm seeing. I could turn off all warnings but that's expressly what I'm trying to avoid. The other referenced post is also for the files that will be compiled, but libraries and headers don't show there so there's no way to set flags on them specifically. I have to assume that there's no way to disable the warning in xcode since it's from the library.Anticlerical
This is bad advice. I believe there are many clang warnings which do not have check boxes in the Build Settings UI. In general setting a specific -W option on the file will fix this problem during compilation. Set the -fdiagnostics-show-option option on a file and clang will tell you which -W to use. In this particular case, this won't work, because OP's question is about the linker, not the compiler.Moreville
Another solution, again for the compiler and not the linker, is diagnostic pragmas: clang.llvm.org/docs/…Moreville
If you are having problems with the new xCode 7 giving you the whole 'this function overrides member but does not declare override' speil; you can add the -Wno-inconsistent-missing-override flag to "other warnings flags" in the same project build settings mentioned aboveJericajericho

© 2022 - 2024 — McMap. All rights reserved.