我试图在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不满意,原因不明。
答案 0 :(得分:3)
如果我导入MessageUI.h
,它现在可以使用了。 (尽管在导入Swift头的类中根本没有使用MessageUI)。
我想我必须导入MessageUI,因为它在桥接头中被引用,并且不包含MessageUI内容的定义...
解决方案:
#import <MessageUI/MessageUI.h>
#import "Oilist-Swift.h"