抑制实例方法覆盖链接器警告框架xcode [英] suppress instance method override linker warning framework xcode

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

问题描述

我有一个库,它开始在 XCode 4.4 下抛出几个链接器警告.警告类似于ld:warning:instance method 'methodName:' in category from overrides method from class in"

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 构建设置区域的Other Linker Flags"中添加标志,我想出了两个选项:

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 的 -w 标志(1)).显然,这将使这个特定的警告安静下来,但所有其他 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天全站免登陆