xcode Swift 编译器错误:使用未声明的类型“EKEventStore”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24177204/
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
Swift Compiler Error : Use of undeclared type 'EKEventStore'
提问by bouh
In swift, I define a class FirstViewController: UIViewController. At the beginning of the file, I have this imports :
在 swift 中,我定义了一个类 FirstViewController:UIViewController。在文件的开头,我有这个导入:
import UIKit
import EventKit
In a method of the class, I have this line:
在类的一个方法中,我有这一行:
var eventStore : EKEventStore = EKEventStore()
I have imported the EventKit.framework
.
我已经导入了EventKit.framework
.
But I have always this Swift Compiler Error : Use of undeclared type 'EKEventStore'.
但我总是遇到这个 Swift 编译器错误:使用未声明的类型“EKEventStore”。
Please help!
请帮忙!
回答by PREMKUMAR
You may be drag and Drop Frameworks for your Project.
您可能是项目的拖放框架。
You must not do like this.
你不能这样做。
Add frameworks : Targets > BuildPhases > Linked Binary and Libraries > And Click + button and Add frameworks like this.
添加框架:目标> BuildPhases> 链接二进制和库> 并单击+ 按钮并像这样添加框架。
then you Import. It will work.
然后你导入。它会起作用。
other option can you try to import EKEventStore Directly.
其他选项可以尝试直接导入 EKEventStore 。
Example : import EKEventStore
例子 : import EKEventStore
回答by bouh
With Deployment Target = 8.0, I have to import the EventKitUI.framework and the Swift Compiler Error disappears. So the header of my class FirstViewController: UIViewController is now :
使用部署目标 = 8.0,我必须导入 EventKitUI.framework 并且 Swift 编译器错误消失。所以我的类 FirstViewController: UIViewController 现在的标题是:
import UIKit
import EventKit
import EventKitUI
Thanks anyway!
不管怎么说,还是要谢谢你!
回答by bouh
I have noticed something : if I change the deployment target from 8.0 to 7.1, the error disappears. I don't understand why.
我注意到一些事情:如果我将部署目标从 8.0 更改为 7.1,错误就会消失。我不明白为什么。