NSGod / ichm

iChm is a CHM reader for Mac OS X
http://www.robinlu.com/blog/ichm
108 stars 26 forks source link

Build error: cannot find protocol declaration for 'WebPolicyDelegate' #3

Closed hanxue closed 8 years ago

hanxue commented 8 years ago

My machine has the following configuration

OSX 10.10.5 Xcode 6.4 Build version 6E35b

I run the following build command

xcodebuild -project /tmp/ichm-1.5/ichm.xcodeproj/ -target "iChm" SYMROOT=build -verbose

And got this error

The following build commands failed:
    CompileC build/ichm.build/Release/iChm.build/Objects-normal/x86_64/ITSSProtocol.o ITSSProtocol.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Full output of xcodebuild here https://gist.github.com/hanxue/c39b6ea7e8457ff2130278ff11c19b03

NSGod commented 8 years ago

Prior to the OS X 10.11 SDK, <WebUIDelegate> was an informal protocol. In other words, since you're building against the OS X 10.10 SDK, the WebUIDelegate is defined as:

@interface NSObject (WebUIDelegate)
// various methods
@end

In the OS X 10.11 SDK, it became a formal protocol.

You can do a couple of things.

  1. Upgrade to Xcode 7.2.1 which includes the OS X 10.11 SDK and runs in OS X 10.10.5 (the same OS X I'm running here).
  2. Otherwise, you could try doing a forward declaration in CHMDocument.h
@protocol WebUIDelegate;

@interface CHMDocument : NSDocument <NSToolbarDelegate, WebPolicyDelegate, WebResourceLoadDelegate, WebFrameLoadDelegate, WebUIDelegate> {

That may allow the code to compile, though you may get warnings about not finding a definition for the protocol.

3.Alternatively, you could simply remove WebUIDelegate from the list of protocols CHMDocument conforms to, by changing:

@interface CHMDocument : NSDocument <NSToolbarDelegate, WebPolicyDelegate,
                    WebResourceLoadDelegate, WebFrameLoadDelegate, WebUIDelegate> {

to:

@interface CHMDocument : NSDocument <NSToolbarDelegate, WebPolicyDelegate,
                                    WebResourceLoadDelegate, WebFrameLoadDelegate> {
NSGod commented 8 years ago

Looking into this more, and will try to make the project as backward compatible as possible.

NSGod commented 8 years ago

This issue should now be fixed in bfc5d047b260a36cfa38757a8e08065b1eaa5bad.