Swift & ObjC bridge - cannot find protocol declaration for "WKNavigationDelegate"

Viewed 1713

I saw there are many questions about Swift and Objective-C bridge including this one, this one, and this one.... But none of them helped me so far.

When adding WKNavigationDelegate and WKScriptMessageHandler, compiler fails with message "Cannot find protocol declaration".

Project-Brigding-Header.h

#import <WebKit/WebKit.h>
#include "xyz.h"

I have added WebKit.framework to Link Binary With Libraries under target > Build Phases. And made changes to build settings.

Defines Module : YES
Always Embed Swift Standard Libraries : YES
Install Objective-C Compatibility Header : YES

Do I have to do anything else to make it work?

1 Answers

Why you are using #import <WebKit/WebKit.h> in the bridging header?
Just add in a top of swift's file:

import WebKit 

The bridging header only for application's inner classes which written with Objective-C.
WebKit is a module (in swift's term).
P.S. Also remove #import from the bridging header.

Related