Parse SDK in swift

When I was a newbie to swift, I spent a lot of hours getting this working.

Setup:  Xcode 6+, Parse SDK 1.6.2+, iOS 8+

Setting up Parse SDK in Xcode

  1. Create a new account at Parse.com
  2. Create a new Application
    parse-swift1
  3. Once your app is set up, Parse will provide you your keys. Note these keys and keep them safe
    parse-swift-2
  4. From the Downloads section of Parse.com, download the SDK

Set up your Xcode project

  1.  Create a new Xcode project and remember to select the Language as Swift
  2. Once the Application is created, click on your Project and go to “Build Phrases”.
    In the List “Link Binary With Libraries” you will have to add these Frameworks to use Parse.parse-swift-3AudioToolbox.framework
    CFNetwork.framework
    CoreGraphics.framework
    CoreLocation.framework
    libz.dylib
    MobileCoreServices.framework
    QuartzCore.framework
    Security.framework
    StoreKit.framework
    SystemConfiguration.framework
    libsqlite3.dylib
  3. Now drag the Parse.framework you downloaded before into your Xcode Project. Remember to check “Copy Items if needed” when you bring in the framework file

Make Parse SDK useable in Swift

Parse SDK is written in Objective-C. In order to use Objective C code in a swift project, you need to link the Objective-C header files using a special Bridging file. You can make Xcode do the work of setting up an empty bridging file.

  1. Create a new File (File -> New -> File) of type Objective-C File.
  2. You can use any name for this file. I am going to call it Dummy.m. We are not going to use this file. However, this will make Xcode ask you to create the bridging file
    parse-swoft-4
  3. Select yes. Xcode will add 2 files to your project – Dummy.m and the Bridging file. Lets call it BridgingHeader.h
  4. Add the following to your BridgingHeader.h
    #import <Parse/Parse.h>