trduong / iOS_Template

Template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About This Template

This project contains several iOS templates. "Basic" is designed to work standalone as a starting point for iOS applications with Facebook connectivity built-in. "Parse" is designed to work with Parse as its back-end. "Server-Based" is designed to work in concert with a Rails-based server template. Together, the templates will save you 1-3 days of setup grunt work and include:

  1. An Xcode template that, with one double-click, will generate a working iOS application with Facebook integration via the Facebook iOS SDK.
  2. A Rails Application Template that, with one command line instruction, will generate a complete Rails server to manage the User model and house any other business logic you'd like to create for your application.
  3. A clean, easy to understand and learn networking implementation (using AFNetworking and JSON) that handles communication between the iOS client and server.

Installing and Using This Template

Installing and using the template is pretty easy.

Initial Installation

You'll only have to do this once.

  1. If you plan on using the "Server-Based" template, follow the instructions for downloading and setting up your Rails server using the accompanying Rails Application Template.
  2. Download the ZIP file containing all of the contents of this template.
  3. Name the unzipped folder something you'd like to see in Xcode (e.g., "Facebook") and copy it to your ~/Library/Developer/Xcode/Templates folder.

Create a Facebook App

You'll follow the remainder of these instructions each time you want to use the template to create a new app.

First, we need to create a Facebook app.

  1. Follow the instructions (in Step 4) to create a Facebook App.
  2. Once the app is created, visit the Developer Apps page and click on it in the left navigation area.
  3. Click the "Edit Settings" link under the Settings banner (near the right margin).
  4. Click on the checkmark next to the "Native iOS App" entry and add your bundle identifier.
  5. A bundle identifier should take the form of com.yourcompanyname.yourappname. For example, com.facebook.shuttlefinder. This should match exactly the bundle identifier specified in the Info.plist file of your Xcode project (below).
  6. Take note of your "App ID" and the bundle identifier for later steps.

Template Instructions

Now we'll go into Xcode and start building our app!

  1. Fire up Xcode.
  2. Select File > New Project.
  3. In the "Choose a template for your new project" dialog, look in the iOS section of the left navigation for the name of your folder in step 3.
  4. Double-click on the icon corresponding to the type of app you'd like to build in the "Choose a template" dialog box.
  5. Supply your Product Name. This should be the same as the "yourappname" section of your bundle identifier in step 8.
  6. Supply your Company Identifier. This should be the same as the "com.yourcompanyname" section of your bundle identifier in step 8.
  7. Supply your Facebook App ID and Facebook Display Name.
  8. If you're going to use the Parse template, supply your Parse Application ID and Parse Client Key.
  9. After clicking next, you need to go into the Info.plist file and modify the Facebook App ID in two locations and replace the underscore with the first digit of your Facebook App ID. An Apple "feature" prevents us from copying the first character of a string comprised of all numbers.

Add Libraries

The iOS template is dependent on external libraries:

  • The Facebook SDK for iOS is Facebook's library for managing login, interaction with the built-in functionality in iOS 6.0, and presenting view controllers for managing friends lists, places, and other information. Every template requires this library.
  • The Parse SDK for iOS provides all the functionality you need to connect to Parse as your back-end service.
  • The AFNetworking stack is a great library for communicating with back-end services (such as our Rails Application Template). This template only scratches the surface of the stuff AFNetworking can do.

These libraries change frequently, so rather than bundling them in our template, we've made these final steps manual. Forgive us.

  1. Download the latest Facebook iOS SDK and install it according to the instructions.
  2. Download the latest Parse SDK for iOS and install it according to the instructions.
  3. Follow the instructions to add the Facebook SDK to your Project.
  4. If you're planning on using the "Server-Based" template, follow the instructions to download and install the AFNetworking library.
  5. Compile and run your application in the iOS 6.0 Simulator.

That's it!

Additional Resources

There are two absolutely invaluable resources for all beginners wanting to build iOS apps that connect to Rails servers:

  1. Want to learn iOS programming VERY quickly and correctly? Check out the Big Nerd Ranch Guide: iOS Programming. This is a truly outstanding book.
  2. Want to become a Rails ninja? You have to start with the Ruby on Rails Tutorial by Michael Hartl. You won't be disappointed.

Pay it Forward

Be excellent to each other!

About

Template