I've defined a protocol in a Swift file that isn't being recognized by an Obj-C header file.
MainViewController.h
#import "AppDelegate.h"
@interface MainViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, AnotherViewControllerDelegate>
@end
In th file above, I'm getting the following error:
Cannot find protocol declaration for "AnotherViewControllerDelegate"; did you mean "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()
}
}
What's strange is that in MainViewController.h, Xcode will autocomplete when I start typing "AnotherViewControllerDelegate". Additionally, "Defines Modules" under Build Settings -> Packaging has always been set to "Yes"; I've mixed Swift and Obj-C methods for other parts of this project's codebase... just can't seem to get this protocol to work.