【发布时间】:2017-10-31 20:30:17
【问题描述】:
我正在尝试在 Objective-C 类中使用自动生成的 Swift 桥接头,但是当我尝试包含它时,我在桥接头中遇到了很多错误。由于标头是自动生成的,因此根本不清楚我可能有什么问题。
在一个 Objective-C 类中,如果我声明以下行,我将得到构建错误 - 没有此行,没有错误并且构建正常:
#import "Oilist-Swift.h"
编辑:我刚刚将#import "Oilist-Swift.h" 语句移到了所有其他标头都已导入之后,现在我只收到与MFMailComposeViewControllerDelegate 相关的错误,并且可能还有一个与PopupStoreControllerDelegate 相关的错误。以下是所有错误:
Angle brackets contain both a protocol ('PopupStoreControllerDelegate') and a type ('MFMailComposeViewControllerDelegate')
Unknown class name 'MFMailComposeViewControllerDelegate'; did you mean 'MFMailComposeViewController'?
Replace 'MFMailComposeViewControllerDelegate' with 'MFMailComposeViewController'
- (void)mailComposeController:(MFMailComposeViewController * _Nonnull)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError * _Nullable)error;
Expected a type (MFMailComposeResult)
我已经查找了循环引用,但目前找不到。
任何见解都将不胜感激!
现在看起来真的很接近了——它似乎只是出于某种未知原因对 MFMail 不满意。
【问题讨论】:
-
看来你的 PopupStoreControllerDelegate 不能在 Objective-C 中使用。你在声明中使用了
@objc吗?您还可能需要在头文件中添加转发@protocol PopupStoreControllerDelegate;。 -
嗯 - PopupStoreControllerDelegate 来自一个 Objective-C 类。您建议将
@protocol添加到哪个头文件?
标签: ios objective-c swift bridging-header