Message:

Quick Start Guide for iOS

This guide will help you getting up and running with Backendless quickly so you can develop iOS applications with it. At the end of the guide you will have a configured working environment and a basic project with the code communicating with Backendless. The instructions use cocoapods to create a project with Backendless libraries. If you do not have Cocoapods installed on your system, make sure to install it per the instructions from the Cocoapods site.

  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. Create a Podfile. This can be done by running:
  4. Open your Podfile using your favorite text editor (or Xcode), and add the following text inside of the target  block:

    The “instruction” shown above will install the iOS version of the Backendless library without support for streaming media. To get Backendless with streaming media API use the following text instead: pod 'Backendless-ios-SDK'. If you plan on using Backendless to build an OSX app, use the following: pod 'Backendless-osx-SDK'. It is important that only one Backendless pod is referenced.
  5. Save the Podfile, return to Terminal window and run:
  6. Once all of the pod data is downloaded, Xcode project workspace file will be created. This should be the file you use everyday to create your app.
  7. IMPORTANT!: Open .xcworkspace file to launch your project. Make sure to open the workspace file. If you just reopen the project, the imported pod will not be picked up!.
  8. If this is a Swift project, click the project root note and select Build Settings. Scroll down to the Swift Compiler – General section. Make sure to add Objective-C Bridging Header for both Debug and Release build types:
  9. Build the project to make sure there are no errors.
  10. If the project uses Objective-C, add the following import statement to the application’s delegate AppDelegate.m file:
  11. If the project uses Objective-C and you are going to use Backendless Media Service for audio/video streaming and playback, also add the following line to AppDelegate.m:
  12. Login to your Backendless account or register to create a new one.
  13. Get your Backendless application and secret keys for iOS from the Backendless Console. The keys can be found on the Manage > App Settings section:
  14. Add Backendless application initialization code block to your application delegate .m file.

    Objective-C:

    Swift:

    At this point the client application setup is complete and the app is ready to communicate with the backend.

  15. Add the following code register in the backend a new user of your app. Instead of michael@backendless.com  used in the code, consider using an email address  where you can check email – your Backendless backend will send out an email welcoming the user to your app.

    Objective-C:

    Swift:

  16. Run your application. A new user will be registered with Backendless. You can verify the registered user in the Data section of the Backendless Console:
  17. In order to experience the Backendless Data Service API declare a new class. Instances of the class can be saved using the Backendless API. The class name is going to be “Comment”, it will also correspond to a table with the same name:

    Objective-C:

    Swift:

  18. Use the following code to the program you already have (where you register the user) to save an instance of “Comment” in Backendless:

    Objective-C:

    Swift:

    Once you run the program and the object is persisted, you can verify in the Backendless Console that the “Comment” data table has been created. Notice the table’s columns match the properties of the Comment class.

Enjoy!