【问题标题】:How to make a particular class file ARC - iphone如何制作特定的类文件 ARC - iphone
【发布时间】:2012-12-05 10:02:06
【问题描述】:

我正在尝试将来自 XMPP 框架的附加 ampp 类文件 XMPPubSub 类集成到我的应用程序中。它说我们必须为这些文件启用 ARC。

我在 Build Phases-> Compile Sources 中为文件添加了 -fobjc-arc 标志。 该类中有这段代码

#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to    ARC).
#endif

即使这样我也得到了这个错误

cc1obj: error: unrecognized command line option "-fobjc-arc"

我已经看过这些链接

1) How to require ARC in a class?

2)How to add ARC for specific file?

3)How to enable ARC for a single file

但还没有运气。我在这里错过了什么吗?

请给点建议

【问题讨论】:

    标签: ios publish-subscribe xmppframework


    【解决方案1】:

    您的项目可能设置为使用错误的编译器。在您的项目设置中,检查您使用的是 Apple LLVM 编译器而不是 LLVM GCC。

    查看演示项目中的这张图片以了解在哪里寻找:

    【讨论】:

    • 是的......我想你是对的。我使用了 Apple LLVM 编译器 4.1.. 但它给出了其他 ARC 错误,例如 ARC Restrictions 错误,这意味着现在文件已被 ARC 转换对了吗?
    • 是的,编译器似乎将您的所有文件都视为 ARC 文件。因此,您应该在每个文件的基础上设置-fobjc-arc(即,仅在 XMPPubSub 上)。在 Build Phases -> Compile Sources 中,找出该文件的位置,然后仅为该文件设置其 ARC 选项。
    • 我已经做到了。在同一个文件中,它显示了其他 ARC 限制错误。我想我会弄清楚的。谢谢 :)
    猜你喜欢
    • 2012-11-03
    • 2012-02-04
    • 1970-01-01
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多