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> #endif

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