需要导入UIKit的新项目文件 [英] New project files requiring the import of UIKit

查看:71
本文介绍了需要导入UIKit的新项目文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目A,我开始用Swift1-Xcode6编写.我有一些扩展文件,例如:

I have a project A, which I started writing with Swift1-Xcode6. I have some extension files like:

extension UIView {
    convenience init(x: CGFloat, y: CGFloat, w: CGFloat, h: CGFloat) {
        self.init(frame: CGRect(x: x, y: y, width: w, height: h))
    }
}

我创建了一个新项目B,并在其中复制了这些扩展文件.我收到此错误:

I created a new project B and copied these extension files in there. I am getting this error:

UIViewExtensions.swift:11:11: Use of undeclared type 'UIView'

Project-A中的文件不需要包含UIKit,而Project-B中的文件则需要.是什么原因?

Files in Project-A do not need the inclusion of UIKit, but Project-B does. What is the reason?

推荐答案

这可能是由于您在桥接头中导入了一些Objective-C框架而恰好在其.h文件中导入了UIKit-这会自动将UIKit导入到您的所有斯威夫特班

This probably happens because you import some Objective-C Frameworks in your bridging header that happens to import UIKit in its .h file - which automatically imports UIKit to all your Swift classes

这篇关于需要导入UIKit的新项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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