抑制实例方法覆盖链接器警告框架 xcode
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11829512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
suppress instance method override linker warning framework xcode
提问by ima747
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 "
我有一个库,它开始在 XCode 4.4 下抛出几个链接器警告。警告沿着“ld:警告:实例方法'methodName:'在类别中来自类中的覆盖方法”
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?
该框架仍然可以正常工作,我认为编写它的公司会在下一个版本中纠正这个问题,但目前这些警告非常烦人。有没有办法在不禁用所有链接器警告的情况下关闭它们?
采纳答案by Carl Lindberg
There are two options I have come up with by adding flags to "Other Linker Flags" in the Xcode build settings area:
通过在 Xcode 构建设置区域中向“其他链接器标志”添加标志,我提出了两个选项:
1) Adding -Xlinker -w
will suppress alllinker 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.
1) 添加-Xlinker -w
将抑制所有链接器警告,无论类型如何(这是-w
ld(1)的标志)。显然,这将消除这个特定警告,但也会消除所有其他 ld 警告。
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.
2) 添加-Xlinker -no_objc_category_merging
将跳过优化步骤,链接器在链接期间将所有类别方法组合到基类中,然后在运行时发生。启动时可能会慢一点,但它可能仍然比运行时的方法调配要快,而且由于 ld(1) 正是在此步骤中发出警告,因此它也将跳过该步骤。
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.
ld 似乎没有办法像编译器那样手术地抑制任何单个警告,尽管它为其中的几个或其中的一组提供了专门的标志(这些都没有帮助)。上述两种解决方案都可能不推荐用于生产代码,但在某些情况下,一种或另一种可能会有所帮助。
回答by apple16
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
Project Navigator(左边的文件列表)-> [Project name](蓝色图标的那个)-> Build Settings -> Apple LLVM compiler 3.1 - Warnings
Also:
还:
In Xcode, how to suppress all warnings in specific source files?