xcode 如何处理`使用未声明的标识符'UIDevice'`
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35507457/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to deal with `Use of undeclared identifier 'UIDevice'`
提问by Creator
I followed the MD file step by step. But there is still an error in the compilation. What can I do?
我是按照MD文件一步一步来的。但是编译还是有错误。我能做什么?
In the FaceppClient.m file :
在 FaceppClient.m 文件中:
if ([[[UIDevice currentDevice] systemVersion] compare: @"5.0" options: NSNumericSearch ] != NSOrderedAscending)
_ios50orNewer = true;
Xcode outputs this error :
Xcode 输出此错误:
Use of undeclared identifier 'UIDevice'
使用未声明的标识符“UIDevice”
I added #import "UIDevice.h"
in the file, but Xcode outputs "UIDevice.h not found"
.
我#import "UIDevice.h"
在文件中添加,但 Xcode 输出"UIDevice.h not found"
.
I added the UIKit
framework to the Project, but I still have the compilation issue.
我将UIKit
框架添加到项目中,但仍然存在编译问题。
What can I do then?
那我能做什么?
回答by Micha?l Azevedo
Try adding this line at the top of your .m file :
尝试在 .m 文件的顶部添加这一行:
#import <UIKit/UIKit.h>
Adding the framework to the project is useful, but you also have to include the needed headers in your code.
将框架添加到项目中很有用,但您还必须在代码中包含所需的头文件。
回答by Peter Brockmann
And for Swift 5 users who got here, try
对于来到这里的 Swift 5 用户,请尝试
import UIKit