Skip to content

Client-side Setup

Setting up your development environment consists of two steps: (1) Xcode project setup and (2) application setup.

Step 1. Xcode Project Setup

Backendless SDK for iOS/macOS includes a library which implements the Backendless APIs. It is recommended to use Cocoapods to configure an Xcode project to use Backendless:

Important

The simplest way to create an Xcode project is by using a Backendless Project Template. See the Quick Start section of this guide for instructions.

CocoaPods manages library dependencies for your Xcode projects. The dependencies for the projects are specified in a plain text file called a Podfile. CocoaPods will resolve dependencies between libraries, fetch the resulting source code, then link it together in an Xcode workspace to build your project. Make sure you have the Cocoapods installed your system as described in the CocoaPods documentation.

To create a new project with Backendless Pod, follow the steps below:

  1. Create a new project in Xcode as you normally would, then close the project.
  2. Open a Terminal window, and change the current directory to be the project's directory.
  3. Run the following command in the Terminal window, which will create a file with the name Podfile.

    pod init
    

  4. Open the created Podfile using a text editor and add the following text inside of the target block:

    pod 'BackendlessSwift'
    

  5. Save Podfile, return to the Terminal window and run the following command:

    pod install
    

  6. Once the pod is downloaded, Xcode project workspace file will be created. This should be the file you use to open the project in Xcode.

  7. Open .xcworkspace file to launch your project.

Important

If your project is written for macOS you should disable sandboxing in capabilities:

Important

sandboxing

Step 2. Application Setup

Once your project is configured, make sure to add Backendless application ID and API key:

  1. Login to Backendless Console, select your app, click Manage and copy the Backendless application ID and API key for iOS:
    app-id-ios-key.zoom80
  2. Add Backendless app initialization code into your app. Make sure to replace APP_ID and API_KEY with specific values.
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [Backendless.shared initAppWithApplicationId:@"YOUR-APPLICATION-ID" apiKey:@"YOUR-APPLICATION-IOS-API-KEY"];
        return YES;
    }
    
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Backendless.shared.initApp(applicationId: "YOUR-APPLICATION-ID", apiKey: "YOUR-APPLICATION-IOS-API-KEY")
    return true
}

At this point the client application is configured and is ready to communicate with the backend.