Cocoafish SDK and Demo App for iOS
Pull request Compare This branch is 15 commits behind appcelerator:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Cocoafish iOS SDK

This open source iOS library allows you to integrate the Cocoafish server backend into your iOS application on iPhone, iPad, and iPod touch.

Except as otherwise noted, the Cocoafish iOS SDK is licensed under the Apache License, Version 2.0 (

Getting Started

The SDK is lightweight. Getting started is easy.

Setup Your Environment

  • If you haven't already done so, set up your iPhone development environment by following the iPhone Dev Center Getting Started Documents.

  • Install Git.

  • Pull this SDK from GitHub:

    git clone git://

Sample Applications

This SDK comes with a sample application that demonstrates authorization, making API calls including user registration, Facebook integration, checkin, place searches and photo uploads to guide you in development.

The Sample appication requires some authorization and API keys inorder to access the services provided by CocoaFish. You will need to obtain these values before you can run the Sample Application. To do so, follow the steps below:

  • Log into cocoafish (

  • View the list of Applications currently registered with your account by selecting the "'s Apps" link from the top menu bar. This should bring you to the Applications page.

  • On the Applications page, you should see a line entitled "Cocoafish Sample App". On that line, click on the "Actions" drop down menu then select the "Show/Edit Apps" option. This will bring you to the Application details page which list the keys used by this Application. Make a note of these keys and their values.

  • Note, the values for all keys except for "Facebook App Id" should be already populated. If you want to use Facebook integration, you will need populate the "Facebook App Id" key with your own ID. To do so, select the "Edit" link at the bottom of the Application Details page.

To build and run the sample application with Xcode (4.0):

  • Open the included Xcode Project File by selecting File->Open... and select samples/DemoApp/DemoApp.xcodeproj.

  • Create a Cocoafish App ID (see If you'd like to integrate your app with Facebook, provide your Facebook app id.

  • Modify Classes/DemoAppDelegate.m to fill in your actual Cocoafish app key (cocoafishAppKey) or OAuth consumer key (oauthConsumerKey) and secret (oauthConsumerSecret), along with an optional Facebook App id (facebookAppId). If you are using Facebook integration, you will need to modify the didFinishLaunchingWithOptions method so that the Cocoafish object is initialized with the Facebook App ID, there is comment above the cocoafish initialization line which shows you how to do this.

  • Finally, select Product -> Build to build the application and then Product -> Run to launch it.

  • Select view/edit places to add a couple places to your app.

APIs Application

The APIs application under samples provides a list of API calls supported by SDK.

Integrate With Your Own Application

Follow these steps to integrate Cocoafish with an existing application:

  • Create your own ios project, for example -- client.

  • Select add files to 'Your project'. Go to cocoafish-ios-sdk/src and select the Cocoafish, ASIHTTPRequest and FBConnect folders. Make sure to check create groups for added folders.

  • Add YAJL.framework to your project. There are two copies of YAJL.framework under cocoafish-ios-sdk/src. One copy is under cocoafish-ios-sdk/src/YAJL.framework, another is under cocoafish-ios-sdk/src/ARMv7s-YAJL-framework. We suggest you add cocoafish-ios-sdk/src/ARMv7s-YAJL-framework to your project, which is the newest version for ARMv7s. If you get any errors when using ARMv7s-YAJL-framework, please switch to the older version which is located in cocoafish-ios-sdk/src/YAJL.framework.

  • Add libz.1.2.3.dylib, SystemConfiguration.framework, MobileCoreServices.framework, CoreLocation.framework and CFNetwork.framework to your project.

  • Under Other Linker Flags in your target, add -ObjC and -all_load

  • You should now be able to build and use all the Cocoafish APIs.


Begin by instantiating the Cocoafish object:

import "Cocoafish.h"

If you choose to use Cocoafish app key,

[Cocoafish initializeWithAppKey:cocoafishAppKey customAppIds:nil];

If you choose to use Cocoafish oauth consumer key and secret,

[Cocoafish initializeWithOauthConsumerKey:oauthConsumerKey consumerSecret:oauthConsumerSecret customAppIds:nil];

If you want to use facebook integration:

[Cocoafish initializeWithAppKey:cocoafishAppKey customAppIds:[NSDictionary dictionaryWithObject:facebookAppId forKey:@"Facebook"]];

or [Cocoafish initializeWithOauthConsumerKey:oauthConsumerKey consumerSecret:oauthConsumerSecret customAppIds:[NSDictionary dictionaryWithObject:facebookAppId forKey:@"Facebook"]];

Then add:

  • (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [[Cocoafish defaultCocoafish] handleOpenURL:url]; }

to yourappDelegate.m

Don't forget to edit your app-info.plist to add URL types for your facebook id. See facebook ios sdk for more information.

With the Cocoafish IOS SDK, you can perform all the actions described in