ios - 在 -Swift.h 文件中找不到 'UNUserNotificationCenterDelegate' 的协议(protocol)声明

标签 ios objective-c swift

我试图将我的 Objective-C AppDelegate 转换为 Swift AppDelegate。所以我删除了 main.m 文件并将所有 AppDelegate 代码转换为 swift。我尝试运行该项目,然后出现此错误。

Cannot find protocol declaration for 'UNUserNotificationCenterDelegate'

在他们生成的 -Swift.h 文件中,这是他们展示的委托(delegate)

- (void)userNotificationCenter:(UNUserNotificationCenter * _Nonnull)center willPresentNotification:(UNNotification * _Nonnull)notification withCompletionHandler:(void (^ _Nonnull)(UNNotificationPresentationOptions))completionHandler SWIFT_AVAILABILITY(ios,introduced=10.0);

我是这样写的

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    handleNotification(notification.request.content.userInfo)
}

请帮我弄清楚我面临的问题是什么。

我尝试过清理、重新启动 Xcode 并重新启动我的 Mac。我正在使用 Swift 3.2。

这是我的-Swift.h 文件错误 enter image description here

如果我评论代表,没有错误。

最佳答案

奇怪的修复,但通过在我的桥接 header 中导入#import,问题得到解决。

关于ios - 在 -Swift.h 文件中找不到 'UNUserNotificationCenterDelegate' 的协议(protocol)声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49429537/

相关文章:

ios - 从 ios 应用程序登录 linkedin

ios - 如何为 iOS Mobile SDK 生成许可证 key

ios - 无法处理应用程序 plist 验证

objective-c - .Net Unicode 编码在 Objective-C 中的等价物是什么?

ios - iOS 应用程序中的 "Expected Identifier"错误

ios - addArrangedSubview 并调整 StackView 的大小

swift - 确定 swift 对象是否具有父类(super class)

ios - Pod 更新后编译 Swift 3.0.1 项目时出错

ios - 在代码周围包装 Async/Main Thread block

objective-c - Apple 示例 'Creating a Block' 中的 block 语法错误