My objective: get https://github.com/couchbaselabs/ToDoLite-iOS syncing with a Couchbase Server and sync gateway on localhost rather than the default demo URL.
I run sync gateway like so: bin/sync_gateway -url http://localhost:8091
And then the only thing I changed in the example is:
-#define kSyncGatewayUrl @"http://demo.mobile.couchbase.com/todolite"
+#define kSyncGatewayUrl @"http://localhost:4984/sync_gateway/"
And when I run
Error: Error Domain=CBLHTTP Code=404 "404 not_found" UserInfo=0x7ff11941fb50 {NSURL=http://localhost:4984/sync_gateway/_facebook, NSLocalizedFailureReason=not_found, NSLocalizedDescription=404 not_found}
How do I fix this?
I solved it. The reason is that I ran
sync_gatewaywithout enabling Facebook registration support.Normally this is done in
config.jsonfile. In fact, this configuration file was supplied in ToDoLite all along.It is crucial that you launch
sync_gatewaywith this configuration file. The README actually states this but in a loose and casual way...NB: I assume above that
sync_gatewayhas been made accessible through$PATH. It's a good idea to do that anyway.Also, I didn't pay attention to the
dbname. So you'll need to replacewith
So, what's the complete sequence of steps to get it working?:
If you want to wipe everything on the server,
rm -rf Library/Application\ Support/Couchbaseand start over. Homebrew cask hides this setting somewhere else where it's hard to reset so a manual install is very recommended.Install Couchbase Server
Set up login credentials if fresh install; otherwise just login
Create a bucket (a database) with name
todoson the cluster. This is thedbnameused by TODOLite.Launch sync gateway. Be sure to pass in the replication URL AND the JSON config file.
bin/sync_gateway -url http://localhost:8091 sync-gateway-config.json; keep sync gateway runningIn the TODOLite
AppDelegate.m, changekSyncGatewayUrl:#define kSyncGatewayUrl @"http://localhost:4984/todos". Notice the name of the database is necessary!(Optionally) Access the administrator interface of the sync gateway by going to
http://localhost:4985/_admin/db/sync_gateway/sync. You can set up the sync function here.In case you're wondering where those port numbers came from, check out