CBLAuthenticator

94 views
Skip to first unread message

Arash Ashrafi

unread,
Aug 8, 2014, 8:40:32 AM8/8/14
to mobile-c...@googlegroups.com

This bit of code:
id<CBLAuthenticator> auth;
auth = [CBLAuthenticator basicAuthenticatorWithName: username
                                           password: password];
from:

doesn't work. Doesn't recognise CBLAuthenticator.

Jens Alfke

unread,
Aug 8, 2014, 11:32:00 AM8/8/14
to mobile-c...@googlegroups.com
Are you sure you have Couchbase Lite 1.0 and not a beta version? (CBLAuthenticator was added after beta 3.)

One way to tell is to look inside CouchbaseLite.framework and see if Headers/CBLAuthenticator.h exists.

—Jens

Arash Ashrafi

unread,
Aug 8, 2014, 12:15:40 PM8/8/14
to mobile-c...@googlegroups.com
I am using version 1.0.1.
The header file also exists in framework.
The CBLAuthenticator protocol is fine. The CBLAuthenticator class is the problem.

Error message: 
use of undeclared identifier 'CBLAuthenticator'

Jens Alfke

unread,
Aug 8, 2014, 2:12:25 PM8/8/14
to mobile-c...@googlegroups.com

On Aug 8, 2014, at 9:15 AM, Arash Ashrafi <arashe...@gmail.com> wrote:

The CBLAuthenticator protocol is fine. The CBLAuthenticator class is the problem.

It's declared in the header:

/** The CBLAuthenticator class provides factory methods for creating authenticator objects, for use
    with the .authenticator property of a CBLReplication. */
@interface CBLAuthenticator : NSObject
@end

What does your code look like and what's the exact compiler error?

—Jens

Arash Ashrafi

unread,
Aug 11, 2014, 4:24:48 AM8/11/14
to mobile-c...@googlegroups.com

1.    id<CBLAuthenticator> auth;

2.    auth = [CBLAuthenticator basicAuthenticatorWithName:@"something" password:@"something"];


First line is fine. 

Error in second line: ! Use of undeclared identifier 'CBLAuthenticator' 

Jens Alfke

unread,
Aug 11, 2014, 1:17:37 PM8/11/14
to mobile-c...@googlegroups.com

On Aug 11, 2014, at 1:24 AM, Arash Ashrafi <arashe...@gmail.com> wrote:

Error in second line: ! Use of undeclared identifier 'CBLAuthenticator' 

Weird. There is a class CBLAuthenticator, and there's only ever been one revision of the header so it can't be that you have an old revision.

My best guess is that you mistyped the class name. It's possible there's an invisible control character in it (try turning on Show Invisibles) — that's happened to me once or twice.

If you still can't figure it out, email me the source file.

—Jens

Arash Ashrafi

unread,
Aug 12, 2014, 3:41:10 AM8/12/14
to mobile-c...@googlegroups.com
It is weird indeed.

To avoid misspelling and invisible characters, this time I copied the class name and method name from header file. Still, same issue.

There is no specific source code that I can send you. Because basic authenticator factory method didn't work any where in my code, for now, I am just inserting the username and password into my remote url manually. (I checked the source code for [CBLAuthenticator basicAuthenticationWithName:password:] and it seems it does the same thing).

Any way, these two lines of code doesn't work anywhere in my code:

1.    id<CBLAuthenticator> auth;

2.    auth = [CBLAuthenticator basicAuthenticatorWithName:@"something" password:@"something"];

And the strange thing is, the first line (the protocol) is fine and it just does not recognise the second line. And it is despite the fact that both CBLAuthenticator protocol and CBLAuthenticator class are declared in the same header file !



Jens Alfke

unread,
Aug 12, 2014, 11:52:07 AM8/12/14
to mobile-c...@googlegroups.com

> On Aug 12, 2014, at 12:41 AM, Arash Ashrafi <arashe...@gmail.com> wrote:
>
> 1. id<CBLAuthenticator> auth;
> 2. auth = [CBLAuthenticator basicAuthenticatorWithName:@"something" password:@"something"];

I assume your actual code doesn't have line numbers at the start :)

I copied and pasted those lines into Grocery Sync, and they compile fine. Can you try the same thing?

—Jens

Arash Ashrafi

unread,
Aug 13, 2014, 3:37:50 AM8/13/14
to mobile-c...@googlegroups.com
Now I can guess what is going on.

The CBLAuthenticator.h is not included in the list of imported header files in CouchbaseLite.h. That might be the reason for that.

And, CBLAuthenticator protocol was known to compiler only because there is a forward declaration of it (@protocol CBLAuthenticator;) in CBLReplication.

By the way, the problem is solved if I include this:
#import "CouchbaseLite/CBLAuthenticator.h"
in addition to:
#import <CouchbaseLite/CouchbaseLite.h>

I wonder why I didn't notice it before :(

Thanks Jens



Jens Alfke

unread,
Aug 13, 2014, 1:28:42 PM8/13/14
to mobile-c...@googlegroups.com

On Aug 13, 2014, at 12:37 AM, Arash Ashrafi <arashe...@gmail.com> wrote:

The CBLAuthenticator.h is not included in the list of imported header files in CouchbaseLite.h. That might be the reason for that.

Oh! Good catch. I didn't notice that because I added it to CouchbaseLite.h back in June (commit 2c22ce7020f2), but that's not in a release yet.

—Jens
Reply all
Reply to author
Forward
0 new messages