Total Swift newbie and Couchbase newbie here! I was looking at the training guide here and quickly realised the tutorial denotes an Objective-C implementation. I was wondering if there’s any similar training guide out there with a Swift implementation? Anything would be helpful! I tried looking at the Swift implementation of the Couchbas mobile Grocery-Sync project but found that a bit hard to follow
We have some documentation content available in Swift, like the code examples in the reference docs, but I don’t believe we have entire tutorials written in Swift that are available yet. (We have one in progress, but it’s not ready yet.)
In general, if you want to get into iOS or Mac development, it’s still pretty important to learn Objective-C, since most documentation, examples and sample code you’ll run into are still written in it. You don’t necessarily need to be able to write it, just read it. Fortunately the syntax is pretty simple (even if it looks weird at first) and easy to learn, and the deeper levels like classes and objects are (intentionally) the same as in Swift.
I have a 20% time project that I’m writing in Swift which is up on Github:
Hope this helps!
Where would I find the examples in the reference docs. What I am looking for is help writing a command-line Swift program that interacts with the Couchbase server.
Couchbase Server? You’ll need to use one of the server SDKs for that. Probably the C one, since you can call C code from Swift.
Or if you want to talk to Sync Gateway, you’d use the REST API. Use NSURLSession to send the requests.
Thanks for the quick response.
So I guess there just isn’t a Swift (or Objective-C) SDK for the server, just for CB Lite.
I don’t know how to call C code from Swift — I’ll look into that.
It’s not super well documented; the basic info is in one Apple’s “Swift and Objective-C” book. There are a bunch of Swift libraries on github that wrap C APIs, that you can look at for examples (e.g. the SQLite API.)