Skip to content

Instantly share code, notes, and snippets.

@andrewsardone
Last active January 31, 2020 17:07
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewsardone/3889904 to your computer and use it in GitHub Desktop.
Save andrewsardone/3889904 to your computer and use it in GitHub Desktop.
A quick cheat sheet for using CocoaPods

CocoaPods project setup

Create a Podfile at the root of your project

platform :ios, '5.0'

pod 'AFNetworking'
pod 'OHAttributedLabel'

target :MyAppTests, :exclusive => true do
  pod 'Kiwi'
end

Then install your project's dependencies

pod install

Configure git to work with Cocoapods:

echo "\n# CocoaPods\nPods" >> .gitignore
git add -f .gitignore Podfile Podfile.lock **/*contents.xcworkspacedata

Luke Redpath points out that checking in your Pods directory has its advantages. Consider not adding it to your .gitignore and simply committing your new Podfile, Podfile.lock, and Xcode workspace.

Bundler

You might consider configuring your project to use Bundler for managing it's dependency on CocoaPods itself. Yes, this is a package manager for your package manager, but it adds an additional explicit declaration of project dependencies and it helps automatically setup boxes with Bundler installed.

bundle install --path vendor/bundle
bundle exec pod install
@supermarin
Copy link

I'm usually adding the :deployment_target on the top as well, like

platform :ios, :deployment_target => "5.0"

@andrewsardone
Copy link
Author

Good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment