Starting a New Project in Xcode

1. Create the Project

Click on File -> New -> Project and create a “Single View” project, and click Next. You’ll be presented with a number of options.

  • Product Name - The product name is just the name of your app, e.g., “Flicks”
  • Organization Name - This is the name of your company, e.g. “Peruzal”
  • Company Identifier - With the above values, this becomes com.peruzal.Flicks. By convention, iOS uses reverse domain name notation for identifiers.
  • Devices - This determines if your app is for the iPhone, iPad, or Universal (both). Use Universal.
  • Language - Use Swift or Objective-C
  • Use Core Data - It will add the boilerplate Core Data setup code for you. Leave it unchecked.

When you click Next, you’ll be prompted for a location to save it. Enable “Create a Git respository.”

2. Add .gitignores

.DS_Store
xcuserdata

.DS_Store files are used by OS X to remember information about the current folder’s window location.

The xcuserdata folder stores you local Xcode data, such as the breakpoints you’ve set.

3. Use a shared scheme

As you change build configurations, you want those changes shared with your team. Click the Application icon drop-down, and choose Manage Schemes.

In the new window, there is one scheme bundled with your app. Check the Shared box.

You will now have an MyProjectName.xcodeproj/xcshareddata folder in your app. Add this file to git.

Setup up CocoaPods

Cocoapods, enables easy addition of libraries into your iOS project. You can use Cocoapods for both managing Swift and Objective-C libraries in the same project.

Install Cocoapods

To install Cocoapods Ruby is required. By default OS X comes with Ruby installed.

  1. Open terminal. You can serach for terminal from the Spotlight.
  2. Run the following command sudo gem install cocoapods. Enter your system password and press Enter to continue.
  3. Once finished, navigate to the project root directory and run pod init.
  4. A Podfile will be created together with a folder Pods that will holds the installed Cocoapods.
  5. You can add CocoaPods to be installed by editing the Podfile e.g. to install SDWebImage

        # Uncomment the next line to define a global platform for your project
        source 'https://github.com/CocoaPods/Specs.git'
        platform :ios, '9.0'
    
        target 'Rotten Tomatoes' do
        # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
        use_frameworks!
        pod 'SDWebImage', '~>3.8'
        end
    
  6. Run the command pod install to install the Cocoapods.

Setting up Cocoapods for the first time

It might take a while to setup Cocoapods for the first time since the gem need to clone the whole CocoaPods repo. The quickest way to setup CocoaPods is to use the following commands :

  1. Open the terminal
  2. Run sudo gem install cocoapods
  3. pod setup
  4. Ctrl+C
  5. pod repo remove master
  6. cd ~/.cocoapods/repos
  7. git clone --depth 1 https://github.com/CocoaPods/Specs.git master

This should not take long to download the required setup to be able to install new Cocoapods.

References

http://stackoverflow.com/questions/21022638/pod-install-is-staying-on-setting-up-cocoapods-master-repo