我试图在 Objective-C 类中使用自动生成的 Swift 桥接 header ,但是当我尝试包含它时,我在桥接 header 中遇到了很多错误。由于 header 是自动生成的,所以根本不清楚我可能有什么错误。
在 Objective-C 类中,如果我声明以下行,我将遇到构建错误 - 没有此行,没有错误并且构建正常:
#import "Oilist-Swift.h"
编辑:我刚刚移动了 #import "Oilist-Swift.h"
在导入所有其他 header 后声明,现在我只收到与 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 不满意。
最佳答案
如果我导入 MessageUI.h
,它现在可以工作了。 (尽管在导入 Swift header 的类中根本没有使用 MessageUI)。
我想我必须导入 MessageUI,因为它在桥接 header 中被引用并且不包含 MessageUI 内容的定义...
解决方法:
#import <MessageUI/MessageUI.h>
#import "Oilist-Swift.h"
关于ios - 不能使用自动生成的 Swift 桥接头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47044051/