Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

The iOS Couchbase Mobile SDK is based on the same Erlang codebase as Syncpoint server. It adds about 3MB to the download size.

The latest download: iOS Couchbase 2.0.1

The download includes: Couchbase Mobile 2.0.1 (An Xcode Framework ready for embedding in your iOS applications), API Documentation, and CouchCocoa, our native client library.

CouchCocoa docs

Here is an introductory screencast to coding with Couchbase on iOS

Jens iOS session from CouchConf SF

Repo manifest if you want to become a contributor. See also Contributing to Couchbase.

Getting Started

These instructions assume you have created a "Frameworks" folder in the root of your Xcode project, and have copied the downloaded Couchbase.framework there. Folks building multiple iOS apps may prefer to store the framework in a shared location. If you didn't put it in the Frameworks subfolder of your project, you'll want to edit the rsync line below in step 5.
 
Wherever you put the downloaded Couchbase.framework, here's how to add it to a project:
 

  1. Open your Xcode project.
  2. Drag the Couchbase.framework into the “Frameworks” section of the file list in your project window. In the sheet that opens, make sure there's a checkbox next to your app's target.
  3. You will need to link some libraries with your project: Go to the target's Build Phases, open "Link Binary With Libraries", click the "" button, and add "libstdc+.dylib", "Security.framework" and "libz.dylib" from the iOS section.
  4. Go to the target's Build Phases and add a new Run Script phase.
  5. Paste the following into the script content of the new phase. (IMPORTANT: This assumes you put the framework in a "Frameworks" subfolder. If you put it elsewhere, update the path in the 2nd argument to ‘rsync’ accordingly.)

Important: The `rsync` command below is a single long line. Do not put a newline in the middle!
    # The 'CouchbaseResources' subfolder of the framework contains 
    # resources needed at runtime. Copy it into the app bundle:
    rsync -a "${SRCROOT}/Frameworks/Couchbase.framework/CouchbaseResources" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
That’s it for the project setup. In your application code, you’ll need to start the CouchbaseMobile server at launch time. See CouchbaseMobile.h for the interface, and seeEmptyAppDelegate.m for an example of how to call it, or stick with us, here is all you need to do:
 
In your MyAppDelegate.h file, add the declaration that you implement the Couchbase protocol, by importing the header file and adding "CouchbaseDelegate" inside the brackets:
#import <Couchbase/CouchbaseMobile.h>

@interface MyAppDelegate : UIResponder <UIApplicationDelegate, CouchbaseDelegate>
In MyAppDelegate.m, in add this code to your didFinishLaunchingWithOptions callback:
CouchbaseMobile* cb = [[CouchbaseMobile alloc] init];
cb.delegate = self;
[cb start];
NSAssert(!cb.error@"Error launching Couchbase: %@", cb.error);
Now all you need is a callback for when Couchbase is ready (and one in case of error):
-(void)couchbaseMobile:(CouchbaseMobile*)couchbase didStart:(NSURL*)serverURL {
    NSLog(@"Couchbase is Ready, go! %@", serverURL);
{color:#002200}}

-
(void)couchbaseMobile:(CouchbaseMobile*)couchbase failedToStart:(NSError*)error {
    NSAssert(NO@"Couchbase failed to initialize: %@", error);
{color:#002200}}
When Couchbase Mobile launches it will call your code with its local serverURL. At that point it is up to you how to interact with it.  Most of our example apps use 
CouchCocoa to interact with Couchbase, but there are plenty of options for how to use Couchbase, with people using everything from raw REST connections, to Core Data interfaces, to WebView interfaces. Couchbase can fit any iOS application.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.