iOS App Development iOS8

Integrate Parse with Swift in iOS8 using CocoaPods

This is a prerequisite for part 2 if you are following the Building Yik Yak Clone

Integrating Mobile backend Service(Parse) in your app

We will integrating parse with swift using CocoaPods instead of the linking the frameworks directly in our apps.

What is CocoaPod

CocoaPods manages library dependencies for your Xcode projects.

The dependencies for your projects are specified in a single 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. For more info CocoaPods

Installing CocoaPod

sudo gem install cocoapods

Create a Podfile in you root directory of your project.

Shrikars-MacBook-Pro:YikYak shrikar$ ls
Podfile           Podfile.lock     Pods            YikYak          YikYak.xcodeproj YikYak.xcworkspace   YikYakTests     home.gpx
Shrikars-MacBook-Pro:YikYak shrikar$ cat Podfile
pod 'Parse-iOS-SDK', '~> 1.3'

Install dependencies.
pod install

At this point a new YikYak.xcworkspace will be created in the root folder of your project. We need to start using this project instead of using YikYak.xcodeproj directly. But before we do that lets close our current project in the xcode as show below


Now open the YikYak.xcworkspace in your workspace and it should look something like this.


Parse Integration

Create an account on Parse if you havent already have one. Create a new app -> head to quickstart -> Data -> Mobile -> Objective-C -> Existing Projects scroll down and you will see a section Connect to your parse app and has objective C code like below. Replace xxxx with your own keys

[Parse setApplicationId:@"xxxxxxx" clientKey:@"xxxx"];

Convert the above into Swift code as below

Parse.setApplicationId("xxxxx", clientKey: "xxxxx")

And copy the above code to AppDelegate.swift didFinishLaunchingWithOptions

Since Parse sdk for iOS is written in ObjectiveC we need to create a bridging header to make it work with our swift app.

Create a new header file in this format ProjectName-Bridging-Header.h so in our case it will be YikYak-Bridging-Header.h with these contents

//  YikYak-Bridging-Header.h
//  YikYak
//  Created by Shrikar Archak on 1/3/15.
//  Copyright (c) 2015 Shrikar Archak. All rights reserved.

#ifndef YikYak_YikYak_Bridging_Header_h
#define YikYak_YikYak_Bridging_Header_h
#import <Parse/Parse.h>

At this point you should be able to compile you project and have integrated Parse in you iOS 8 swift app.

About the author


Backend/Infrastructure Engineer by Day. iOS Developer for the rest of the time.

  • Алексей Субботкин

    Parse-iOS-SDK pod has been deprecated, use Parse pod.

  • Mike Tickle

    When I issue the command pod install I get an error:

    “ArgumentError – Illformed requirement `”~> 1.3″

    My podfile contains the single line “pod ‘Parse-iOS-SDK’, ‘~> 1.3′” as in the example above so any ideas on what to do to fix?

  • Allen Guan

    Hi Shrikar, which dependencies do I need to install for this project? Thanks!