禁止实例方法重写链接器警告框架xcode [英] suppress instance method override linker warning framework xcode

查看:130
本文介绍了禁止实例方法重写链接器警告框架xcode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个库开始根据XCode 4.4抛出一些链接器警告.警告遵循"ld:警告:类别中实例方法'methodName:"的类别,覆盖"

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?

推荐答案

通过在Xcode构建设置区域的其他链接器标志"中添加标志,我想到了两种选择:

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

1)添加-Xlinker -w将禁止 all 链接程序警告,无论其类型如何(这是ld(1)的-w标志).显然,这将使此特定警告安静下来,但所有其他ld警告也将取消.

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)添加-Xlinker -no_objc_category_merging将跳过优化步骤,在该步骤中,链接器在链接期间将所有类别方法组合到基类中,然后会在运行时发生.可能在启动时会稍微慢一点,但是它可能仍然比运行时的方法混乱要快,并且由于ld(1)在此步骤中发出警告,它也会跳过该警告.

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.

看来ld并没有像编译器那样通过外科手术来抑制任何个人警告的方法,尽管它对其中的几个或一组使用了特殊标志(对此毫无帮助).上面的两种解决方案都不推荐用于生产代码,但是在某些情况下,其中一种可能会有所帮助.

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.

这篇关于禁止实例方法重写链接器警告框架xcode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆