suppress instance method override linker warning framework xcode

后端 未结 2 550
后悔当初
后悔当初 2021-01-01 12:32

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 catego

2条回答
  •  长发绾君心
    2021-01-01 12:53

    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.

提交回复
热议问题