如何:忽略自动生成的“<project>-Swift.h"警告 [英] How to: Ignore autogenerated &quot;&lt;project&gt;-Swift.h&quot; warnings

查看:88
本文介绍了如何:忽略自动生成的“<project>-Swift.h"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 Swift 和 Objective-C 代码的项目.除了一个带有项目名称和后缀 -Swift.h 的文件外,我没有任何警告,它是从 Swift 文件自动生成的标题.

I have a project with both, Swift and Objective-C code. I have no warnings except one file with the project name and then the suffix -Swift.h, it is the auto generated header from the Swift files.

此文件不在我的项目导航器中,也不在 Finder 中项目的文件夹中.我在构建阶段找不到它来添加 -fno-objc-arc.

This file is not in my project navigator nor in the folder of the project in the Finder. I can not find it in the Build Phases to add -fno-objc-arc.

更改文件并添加代码以抑制警告将在我下次构建应用程序时删除.

Changing the file and adding code to suppress the warning will be deleted the next time I build the app.

文件顶部是一行

// Generated by Swift version 1.0 (swift-600.0.47.8)

如何在不禁用项目中其他文件的有用警告的情况下消除此警告?

How can I get rid of this warning without disabling the helpful warnings for the other files in my project?

警告示例:

默认属性属性 'assign' 不适用于非 GC 对象

Default property attribute 'assign' not appropriate for non-GC object

未指定 'assign'、'retain' 或 'copy' 属性 - 假定为 'assign'

No 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed

<小时>

Swift 代码:

@objc class ... {
    internal var label: Identifier
}

自动生成的代码(两种警告类型):

SWIFT_CLASS("_TtC12...")
@interface ...
@property (nonatomic) Identifier * label; // warnings here
@end

推荐答案

这个对原始问题的评论为我解决了这个问题.一旦我转换了将生成的 Swift.h 文件导入到 ARC 的非 ARC Objective-C 类,警告就消失了.

This comment on the original question solved it for me. Once I converted the non-ARC Objective-C classes that were importing the generated Swift.h file to ARC the warnings went away.

我也遇到了同样的问题.原来我有一个旧的objective-c我设置了 -fno-objc-arc 编译器标志的类和这个objective-c类导入 -swift.h 导致此警告非常合理.最终我制作了 Objective-c 类来支持 ARC 和警告消失了.– Berby Huang 2014 年 9 月 19 日 5:18

I had this issue the same. It turns out that I have an old objective-c class which I set -fno-objc-arc compiler flag to and this objective-c class imports -swift.h which causes this warning very reasonably. Eventually I made the objective-c class to support ARC and the warning is gone. – Berby Huang Sep 19 '14 at 5:18

这篇关于如何:忽略自动生成的“<project>-Swift.h"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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