Parse Backend with Swift!

So you have the next best app idea and you begin coding! Next thing you realize is that you need a way to store photo's, files, array's, strings and dates in the cloud but you don't know how to set up a server. What do you do? You turn to a great ready to use tool called Parse.

With Parse you can instantly add a powerful cloud database, push notification services, and analytics tracking to your app. -

So how do you get started? Follow along and by the end of the tutorial you will be able to add the ParseSDK to your project, have the database and your app talking also setting up a user in the cloud.

This tutorial assumes you know how to set up an xcode project.

Step 1: Set up a blank xcode project titled 'Parse Example'

Step 2: Set up Cocoapods


The first item of business we must take care of is setting up Cocoapods. Cocoapods you can think of as a third party framework manager.

Using the terminal:

  1. $ cd into your project directory.
    Create a Podfile. This can be done by running $ vim podfile .
  2. In terminal type $ vim podfile
  3. In your podfile type:

platform :ios, '7.0'

pod 'Parse'

Save your podfile.
4. In terminal type $ pod install
5. Finished!

Opening your project

Next close your terminal and go into your project directory. You will now see an xcode.proj and xcode.xcworkspace. You must open .xcworkspace to use the new frameworks.

In order to use Parse we'll have to set up a few items:

Step 1. Add these frameworks in xcode. First click on project, go to Build Phases, and find Link Binary with Libraries and add these frameworks:



Step 2. We need to add a Bridging Header File. This is a file that will help us bridge the framework with Parse.

  1. Go to File and select: New<File
  2. Choose Objective-C File
  3. Name it 'ParseBridgingHeader'
  4. Choose Next and save. You will be asked if you would like to use this file as an Objective-C bridging header file, choose Yes.
  5. It will add two files a .m and a .h. You can delete the .m
  6. In the .h add "#import Parse/Parse.h>" This will import Parse into your project!!



Using Parse

  1. Now before we begin coding we must now set up our backend server. So go to Here and register, if you already are registered go to next step!
  2. After you sign in click on the dashboard and create a new app. Name it whatever you like and click create.
  3. Click on your app and go to settings. Under settings you will see a navigation panel on the left. Click keys. Here you will see the Application ID key and the client key. you will need these in the next section.


Coding Time

Now that our app has a backend server set up, we need to tell the app about it. To do this we will add our keys from the previous section. Go to your app delegate file In the didFinishLaunchingWithOption function add this function.

Parse.setApplicationId(“your_application_key”, clientKey: “your_client_key”)

Next go to your viewController.swift file.

This next piece of code will make a new class and upload it to the cloud. This will test and see if everything set up so far is valid.

var object = PFObject(className: "TestClass")
object.addObject("iOS-Developers", forKey: "bestSlackGroup")
object.addObject("iPhone", forKey: "bestSmartPhone")


Now go to your app on and you will see a brand new class with the values we filled in!! If you do not see the class or experience an error, make sure your keys are correct. If they are correct make sure the Parse.framework is added correctly.


You've just connected your first backend with swift!

Whats Next?

In future tutorials I will walk you through using the iPhones camera and uploading images to parse, as well as displaying information coming from parse. Next tutorial will be creating a user and a mini profile!