Home

Day 1: Install Xcode, Ruby and CocoaPods

Environment

Xcode

Apple provides a official development tool called Xcode. It's completely free of charge, let's get it.

Download and Install

  1. Launch App Store.
  2. Search by Xcode.
  3. Get -> Install App

Please wait...

A First project

Following installation, let's create a first project. It's the simplest app commonly called "Hello, world!".

Create

  1. Launch Xcode.
  2. Create a new Xcode project.
  3. iOS -> Application -> Single View Application
  4. Choose options for you new project as below:

Run

  1. Click Build and then run the current scheme button on left top.
  2. Enable Developer Mode on this Mac? -> Yes
  3. You can see the app with white screen.

  4. If simulator window is too large, select scale. (Window -> Scale -> 75%, 50%...)

  5. I always use iPhone 6s simulator.

Ruby, CocoaPods

When we create a full-scale application, we must take the help of 3rd party libraries. CocoaPods and Carthage is famous tool to manage dependencies with libraries. I recommend CocoaPods for beginners.

It's written by Ruby. So we'll install CocoaPods with Ruby.

Update Ruby

First, launch Terminal: Applications -> Utilities -> Terminal * Recommend: Keep in Dock

$ ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
$ which ruby
/usr/bin/ruby

Ruby is installed on your mac by default, but it's too old. So we'll update it to latest version with rbenv.

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Restart Terminal.

$ rbenv install 2.2.3
$ rbenv global 2.2.3

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
$ which ruby
/Users/tnantoka/.rbenv/shims/ruby

Install CocoaPods

We only need to run one command.

$ gem install cocoapods
$ pod --version
0.39.0

That's all. Now, you've got a development environment for your first iPhone app!