Has anyone been able to get GrocerySync-swift-2 to compile?

43 views
Skip to first unread message

Brendan Duddridge

unread,
Sep 23, 2015, 2:39:28 PM9/23/15
to Couchbase Mobile
I've been trying to get the GrocerySync app to compile, but am having some troubles.

It seems like it's referencing classes that are no longer available in Swift, such as MapGenerator, etc.

I've filed an issue for it here:


I've been wanting to get started on peer-to-peer sync with my app.

Also, are there any objective-c examples that do peer-to-peer sync?

Thanks,

Brendan

Jens Alfke

unread,
Sep 23, 2015, 2:48:09 PM9/23/15
to mobile-c...@googlegroups.com

> On Sep 23, 2015, at 11:39 AM, Brendan Duddridge <bren...@gmail.com> wrote:
>
> I've been trying to get the GrocerySync app to compile, but am having some troubles.
> It seems like it's referencing classes that are no longer available in Swift, such as MapGenerator, etc.

Oops, Apple must have changed those APIs in later Xcode 7 betas; it’s been a few months since I looked at that code. I’ll try to get it fixed. Thanks for filing an issue.

> Also, are there any objective-c examples that do peer-to-peer sync?

I don’t know of any. I decided to write mine in Swift as a way to learn the language better, and because we already have a lot of Obj-C sample code. The basics are really simple (tell Listener to publish via Bonjour; use an NSNetServiceBrowser to discover peers), it just gets more complex if you want to automatically stay in sync instead of doing it as a one-shot.

—Jens

Brendan Duddridge

unread,
Sep 23, 2015, 3:44:16 PM9/23/15
to Couchbase Mobile
Thanks Jens for the reply. Yes, I definitely want to do automatic sync rather than a one-shot. And to make things a bit more complicated, I'm syncing multiple databases, each one within their own NSDocument bundle. I know we talked about that before, so I won't re-hash it here.

Looking forward to the fix. I've tried to dig into it, but my Swift experience is lacking so haven't been able to figure out how to get it to compile.

Thanks,

Brendan

Brendan Duddridge

unread,
Sep 23, 2015, 4:09:18 PM9/23/15
to Couchbase Mobile
Thanks for posting the fix and with your improvements Jen!

Do I need to disable ATS to make it work though? I get the following error when I test it from my 6 Plus to the Simulator:

SyncedDB[Simmie]: Got latest seq=0

SyncedDB[Simmie]: Got latest seq=0

DatabaseSharer: Publishing seq=1

DatabaseSharer: Publishing seq=2

SyncedDB[Simmie]: Got latest seq=1

SyncedDB[Simmie]: Resolving address

SyncedDB[Simmie]: Pulling from <https://Voyager.local.:59844/grocery-sync> for UUID bc01b0071d58caa8f86f1c80d95d918658e93c34

2015-09-23 14:07:32.442 GrocerySync[285:16733] CFNetwork SSLHandshake failed (-9805)

2015-09-23 14:07:32.444 GrocerySync[285:16733] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9805)

SyncedDB[Simmie]: Replication stopped with error An SSL error has occurred and a secure connection to the server cannot be made.

Jens Alfke

unread,
Sep 23, 2015, 4:30:09 PM9/23/15
to mobile-c...@googlegroups.com

On Sep 23, 2015, at 1:09 PM, Brendan Duddridge <bren...@gmail.com> wrote:

Do I need to disable ATS to make it work though? I get the following error when I test it from my 6 Plus to the Simulator:

There are some issues with P2P SSL connections in 1.1, so until 1.1.1 I’d recommend not enabling SSL in the listener.
That, in turn, means that under iOS 9 you’ll have to disable App Transport Security for the “local” domain.

(1.1.1 should be out today. Apparently the downloads page has been updated and we’re just waiting for the new page to propagate through the series of tubes that is our CMS.)

—Jens

Brendan Duddridge

unread,
Sep 23, 2015, 4:50:25 PM9/23/15
to Couchbase Mobile
Well I've been compiling my own from source so I think I have the latest code. I also tried turning off App Transport Security entirely and it also didn't work. I had to just disable SSL in DatabaseSharer.swift in the Init:

public init(database: CBLDatabase, nickname: String, port: UInt16 = kDefaultPort, ssl: Bool = false) throws



It works really well when it can connect :-)

I've made a new build from source just to be sure I have the latest and I do.

I disabled ATS completely:

<key>NSAppTransportSecurity</key>
<dict>
 
<key>NSAllowsArbitraryLoads</key>
 
<true/>
</dict>




But I still get SSL Handshake errors in the log output:

PeerSyncManager: Saved new nickname 'Optional("Plusser")'
PeerSyncManager: ---- START ---- (Couchbase Lite 1.1+ (unofficial))
DatabaseSharer: My UUID is 'c66a72410f2f58d722bb2e6528eb52ab72293211'
DatabaseSharer: Bonjour name is 'Plusser [c66a72410f2f58d722bb2e6528eb52ab72293211]'
DatabaseSharer: Sharing at <Optional(https://iPhone-6-Plus.local:59844/)>
DatabaseSharer: Sharing database...
DatabaseSharer: Publishing seq=0
Browser found <NSNetService 0x15d5b6d60> local. _peersync._tcp. Simmie6 [bc01b0071d58caa8f86f1c80d95d918658e93c34]
Browser found <NSNetService 0x15d566b80> local. _peersync._tcp. Simmie [bc01b0071d58caa8f86f1c80d95d918658e93c34]
Browser removing <NSNetService 0x15d62c750> local. _peersync._tcp. Simmie [bc01b0071d58caa8f86f1c80d95d918658e93c34]
SAVE
PairingManager: Adding paired OnlinePeer['Simmie6', bc01b0071d58caa8f86f1c80d95d918658e93c34 at #0]
*** Paired OnlinePeer['Simmie6', bc01b0071d58caa8f86f1c80d95d918658e93c34 at #0] went online ***
SyncedDB[Simmie6]: Added OnlinePeer['Simmie6', bc01b0071d58caa8f86f1c80d95d918658e93c34 at #0]; latest seq=0
PairingManager: Saved pairings: ["bc01b0071d58caa8f86f1c80d95d918658e93c34": {
    nick
= Simmie6;
    seq
= 0;
}]

SyncedDB[Simmie6]: Got latest seq=0
SyncedDB[Simmie6]: Got latest seq=1
SyncedDB[Simmie6]: Resolving address
SyncedDB[Simmie6]: Pulling from <https://Voyager.local.:59844/grocery-sync> for UUID bc01b0071d58caa8f86f1c80d95d918658e93c34
2015-09-23 14:46:08.793 GrocerySync[331:27961] CFNetwork SSLHandshake failed (-9805)
2015-09-23 14:46:08.813 GrocerySync[331:27961] CFNetwork SSLHandshake failed (-9805)
2015-09-23 14:46:08.835 GrocerySync[331:27961] CFNetwork SSLHandshake failed (-9805)
2015-09-23 14:46:08.836 GrocerySync[331:27961] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9805)
SyncedDB[Simmie6]: Replication stopped with error An SSL error has occurred and a secure connection to the server cannot be made.




Thanks,

Brendan

Jens Alfke

unread,
Sep 23, 2015, 7:25:20 PM9/23/15
to mobile-c...@googlegroups.com

> On Sep 23, 2015, at 1:50 PM, Brendan Duddridge <bren...@gmail.com> wrote:
>
> Well I've been compiling my own from source so I think I have the latest code. I also tried turning off App Transport Security entirely and it also didn't work.

Well, crap. I feel like I’ve been playing Whack-a-Mole with SSL problems for months, but it’s time for another round. Could you file an issue, please?

—Jens

Brendan Duddridge

unread,
Sep 24, 2015, 12:06:45 AM9/24/15
to Couchbase Mobile
Hey Jens,

Ok, I filed an issue:


Thanks!

Brendan

Brendan Duddridge

unread,
Sep 24, 2015, 12:10:13 AM9/24/15
to Couchbase Mobile
I also still see the issue I posted a while ago:

Syncing P2P stops after receiving an NSNetServices -72003 error



Thanks,

Brendan
Reply all
Reply to author
Forward
0 new messages