Obj-C头文件无法识别Swift类的协议

我已经在Swift文件中定义了一个Obj-C头文件无法识别的协议。

MainViewController.h

#import "AppDelegate.h" @interface MainViewController : UIViewController  @end 

在上面的文件中,我收到以下错误:

找不到“AnotherViewControllerDelegate”的协议声明; 你的意思是“UIPageViewControllerDelegate”?

MainViewController.m

 #import "MainViewController.h" #import "AppDelegate.h" @implementation MainViewController -void closeView{ NSLog(@"Why doesn't this work?"); } @end 

AppDelegate.h

 #import "MyProject-Swift-Headers.h" 

AnotherViewController.swift

 @objc protocol AnotherViewControllerDelegate { func closeView() } @objc class AnotherViewController: UIViewController{ var delegate: AnotherViewControllerDelegate! @IBAction func closeButton(sender: UIButton) { delegate.closeView() } } 

奇怪的是,在MainViewController.h中,当我开始输入“AnotherViewControllerDelegate”时,Xcode将自动完成。 此外,“构建设置 – >包装”下的“定义模块”始终设置为“是”; 我已经为这个项目的代码库的其他部分混合了Swift和Obj-C方法……似乎无法让这个协议工作。