CINXE.COM

CocoaPods Guides - Getting Started

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>CocoaPods Guides - Getting Started</title> <link rel="shortcut icon" href="https://cocoapods.org/favicons/favicon.ico" type="image/x-icon"> <link rel="apple-touch-icon" href="https://cocoapods.org/favicons/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="57x57" href="https://cocoapods.org/favicons/apple-touch-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="https://cocoapods.org/favicons/apple-touch-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="https://cocoapods.org/favicons/apple-touch-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="https://cocoapods.org/favicons/apple-touch-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="https://cocoapods.org/favicons/apple-touch-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="https://cocoapods.org/favicons/apple-touch-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="https://cocoapods.org/favicons/apple-touch-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="https://cocoapods.org/favicons/apple-touch-icon-152x152.png"> <meta charset="utf-8"> <meta content="cocoapods objective-c objc swift package manager libraries documentation search pods podspec podfile cocoa apple ios library" name="keywords"> <meta content="IE=edge" http-equiv="X-UA-Compatible"> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <meta content="The Dependency Manager for iOS &amp; Mac projects" name="description"> <meta content="CocoaPods Dev Team" name="author"> <meta content="summary" name="twitter:card"> <meta content="@CocoaPods" name="twitter:site"> <meta content="@CocoaPods" name="twitter:creator"> <meta content="CocoaPods.org" name="twitter:title"> <meta content="The Dependency Manager for iOS &amp; Mac projects." name="twitter:description"> <meta content="https://www.cocoapods.org/" name="twitter:url"> <link href="../stylesheets/app.css" rel="stylesheet"> <script src="../javascripts/application.js"></script><meta content="CocoaPods Guides" name="twitter:title"> <meta content="The official documentation site for the CocoaPods dependency manager." name="twitter:description"> <meta content="CocoaPods Guides" property="og:site_name"> <meta content="CocoaPods Guides" property="og:title"> <meta content="https://guides.cocoapods.org" property="og:url"> </head> <body> <nav class="navbar navbar-static-top" role="navigation"><section class="container"><div class="navbar-header"> <button class="navbar-toggle" data-target=".navbar-header-collapse" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span><span class="glyphicon glyphicon-plus"></span></button><a class="navbar-brand" href="https://cocoapods.org"></a> </div> <div class="collapse navbar-collapse navbar-header-collapse"><ul class="nav navbar-nav navbar-right"> <li><a href="https://cocoapods.org/about">About</a></li> <li class="active"><a href="https://guides.cocoapods.org">Guides</a></li> <li><a href="https://blog.cocoapods.org">Blog</a></li> </ul></div></section></nav><section class="container"><div class="row"><header class="header content col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1"><h1>Getting Started</h1></header></div></section><div class="guide" id="content-wrapper"><section class="container"><div class="row"><article class="content col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1"><p></p> <div class="col-md-8"> <h2 id="what-is-cocoapods"> <a class="header-link" href="#what-is-cocoapods">&lt;</a>What is CocoaPods</h2> <p>CocoaPods manages library dependencies for your Xcode projects.</p> <p>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.</p> <p>Ultimately the goal is to improve discoverability of, and engagement in, third party open-source libraries by creating a more centralised ecosystem.</p> <p></p> </div> <div class="col-md-4"> <h2 id="prefer-video"> <a class="header-link" href="#prefer-video">&lt;</a>Prefer video?</h2> <p>Google have created a great overview for Route 85 video series going through this entire guide and more.</p> <p><a href="https://www.youtube.com/watch?v=iEAjvNRdZa0&amp;spfreload=10"><img src="../assets/images/guides/google_route_85.jpg"></a></p> <p></p> </div> <div class="clearfix"></div> <h2 id="getting-started"> <a class="header-link" href="#getting-started">&lt;</a>Getting Started</h2> <h3 id="installation"> <a class="header-link" href="#installation">&lt;</a>Installation</h3> <p>CocoaPods is built with Ruby and it will be installable with the default Ruby available on macOS. However, we recommend not using the system provided Ruby and instead installing a newer Ruby version separate from the system installation. You can use a Ruby Version manager such as <a href="https://rvm.io">RVM</a> or <a href="https://github.com/rbenv/rbenv">rbenv</a> to manage multiple Ruby versions, or you can use <a href="https://brew.sh">Homebrew</a> to install a newer Ruby with <code>brew install ruby</code>.</p> <p>Install CocoaPods by running the following command:</p> <div class="highlight"> </div> <div class="code-break"> <section class="container"> <div class="row"> <article class="content col-md-11 col-md-offset-1"><pre class="highlight shell"><code><span class="nv">$ </span>gem <span class="nb">install </span>cocoapods </code></pre> </article> </div> </section> </div> <section class="container "> <div class="row"> <article class="content col-md-10 col-md-offset-1"> </article> </div> <p>If using the default Ruby included with macOS, installation will require you to use <code>sudo</code> when installing gems. (This is only an issue for the duration of the gem installation, though.)</p> <div class="highlight"> </div> </section> <div class="code-break"> <section class="container"> <div class="row"> <article class="content col-md-11 col-md-offset-1"><pre class="highlight shell"><code><span class="nv">$ </span><span class="nb">sudo </span>gem <span class="nb">install </span>cocoapods </code></pre> </article> </div> </section> </div> <section class="container "> <div class="row"> <article class="content col-md-10 col-md-offset-1"> </article> </div> <p>If you encounter any problems during installation, please visit <a href="https://guides.cocoapods.org/using/troubleshooting#installing-cocoapods">this</a> guide.</p> <h3 id="sudo-less-installation"> <a class="header-link" href="#sudo-less-installation">&lt;</a>Sudo-less installation</h3> <p>If you do <em>not</em> want to grant RubyGems admin privileges for this process, you can tell RubyGems to install into your user directory by passing either the <code>--user-install</code> flag to <code>gem install</code> or by configuring the RubyGems environment. The latter is in our opinion the best solution. To do this open up terminal and create or edit your <code>.bash_profile</code> with your preferred editor. Then enter these lines into the file:</p> <div class="highlight"> </div> </section> <div class="code-break"> <section class="container"> <div class="row"> <article class="content col-md-11 col-md-offset-1"><pre class="highlight shell"><code><span class="nb">export </span><span class="nv">GEM_HOME</span><span class="o">=</span><span class="nv">$HOME</span>/.gem <span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span><span class="nv">$GEM_HOME</span>/bin:<span class="nv">$PATH</span> </code></pre> </article> </div> </section> </div> <section class="container "> <div class="row"> <article class="content col-md-10 col-md-offset-1"> </article> </div> <p>Note that if you choose to use the <code>--user-install</code> option, you will still have to configure your <code>.bash_profile</code> file to set the <code>PATH</code> or use the command prepended by the full path. You can find out where a gem is installed with <code>gem which cocoapods</code>. E.g.</p> <div class="highlight"> </div> </section> <div class="code-break"> <section class="container"> <div class="row"> <article class="content col-md-11 col-md-offset-1"><pre class="highlight shell"><code><span class="nv">$ </span>gem <span class="nb">install </span>cocoapods <span class="nt">--user-install</span> <span class="nv">$ </span>gem which cocoapods /Users/eloy/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb <span class="nv">$ </span>/Users/eloy/.gem/ruby/2.0.0/bin/pod <span class="nb">install</span> </code></pre> </article> </div> </section> </div> <section class="container "> <div class="row"> <article class="content col-md-10 col-md-offset-1"> </article> </div> <h3 id="updating-cocoapods"> <a class="header-link" href="#updating-cocoapods">&lt;</a>Updating CocoaPods</h3> <blockquote> <p>To update CocoaPods you simply install the gem again</p> </blockquote> <div class="highlight"> </div> </section> <div class="code-break"> <section class="container"> <div class="row"> <article class="content col-md-11 col-md-offset-1"><pre class="highlight shell"><code><span class="nv">$ </span><span class="o">[</span><span class="nb">sudo</span><span class="o">]</span> gem <span class="nb">install </span>cocoapods </code></pre> </article> </div> </section> </div> <section class="container "> <div class="row"> <article class="content col-md-10 col-md-offset-1"> </article> </div> <blockquote> <p>Or for a pre-release version</p> </blockquote> <div class="highlight"> </div> </section> <div class="code-break"> <section class="container"> <div class="row"> <article class="content col-md-11 col-md-offset-1"><pre class="highlight shell"><code><span class="nv">$ </span><span class="o">[</span><span class="nb">sudo</span><span class="o">]</span> gem <span class="nb">install </span>cocoapods <span class="nt">--pre</span> </code></pre> </article> </div> </section> </div> <section class="container "> <div class="row"> <article class="content col-md-10 col-md-offset-1"> </article> </div> <p>If you originally installed the cocoapods gem using <code>sudo</code>, you should use that command again.</p> <p>Later on, when you're actively using CocoaPods by installing pods, you will be notified when new versions become available with a <em>CocoaPods X.X.X is now available, please update</em> message.</p> <h4 id="using-bundler-to-manage-ruby-dependencies">Using Bundler to manage Ruby dependencies</h4> <p><a href="https://bundler.io/">Bundler</a> is to Ruby what CocoaPods is to iOS. It manages dependencies for a Ruby project. </p> <p>You can use Bundler to pin the version of CocoaPods you want to use, along with any other Ruby projects you may use such as <a href="https://fastlane.tools/">fastlane</a> or <a href="https://danger.systems/">danger</a>.</p> <p>For more info, see <a href="a-gemfile.html">using a Gemfile</a>.</p> <h4 id="using-a-cocoapods-fork">Using a CocoaPods Fork</h4> <p>There are two ways to do this, <a href="a-gemfile.html">using a Gemfile</a> (recommended) or using a <a href="/using/unreleased-features">development build</a> that are in discussion or in implementation stage.</p> <h3 id="using-cocoapods"> <a class="header-link" href="#using-cocoapods">&lt;</a>Using CocoaPods</h3> <p>Head over to <a href="using-cocoapods.html">Using CocoaPods</a> for details on the usage of CocoaPods.</p> </section></article></div></section></div> <div class="info-row"><section class="container"><div class="row"><article class="content col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1"><a data-container="body" data-content="CocoaPods is an open source project. Help us improve these guides by sending a pull request. ❤" data-original-title="" data-placement="top" data-toggle="popover" data-trigger="hover" href="https://github.com/CocoaPods/guides.cocoapods.org/blob/master/source/using/getting-started.html.md" id="pull-request" title=""></a><ul class="breadcrumb"> <li> <a href="../index.html">Home</a><span class="divider"></span> </li> <li> <a href="index.html">Using CocoaPods</a><span class="divider"></span> </li> <li class="active">Getting Started</li> </ul></article></div></section></div> <section class="site_navigation container"><div class="row"> <div class="col-lg-3 col-sm-3 col-xs-6 footer-index"> <h3><a href="index.html">Using CocoaPods</a></h3> <ul> <li><a href="getting-started.html">Getting Started</a></li> <li><a href="using-cocoapods.html">Using CocoaPods</a></li> <li><a href="pod-install-vs-update.html">pod install vs. pod update</a></li> <li><a href="the-podfile.html">The Podfile</a></li> <li><a href="troubleshooting.html">Troubleshooting</a></li> <li><a href="faq.html">F.A.Q</a></li> <li><a href="test-specs.html">Testing with CocoaPods</a></li> <li><a href="a-gemfile.html">Using a Gemfile</a></li> </ul> </div> <div class="col-lg-3 col-sm-3 col-xs-6 footer-index"> <h3><a href="../making/index.html">Build with CocoaPods</a></h3> <ul> <li><a href="../making/making-a-cocoapod.html">Making a CocoaPod</a></li> <li><a href="../making/using-pod-lib-create.html">Using Pod Lib Create</a></li> <li><a href="../making/getting-setup-with-trunk.html">Getting setup with Trunk</a></li> <li><a href="../making/development-cocoapods.html">Development Pods</a></li> <li><a href="../making/private-cocoapods.html">Private Pods</a></li> <li><a href="../making/specs-and-specs-repo.html">Specs and the Specs Repo</a></li> </ul> </div> <div class="clearfix visible-xs"></div> <div class="col-lg-3 col-sm-3 col-xs-6 footer-index"> <h3><a href="../plugins/index.html">Plugins</a></h3> <ul> <li><a href="../plugins/setting-up-plugins.html">How to use CocoaPods plugins</a></li> <li><a href="../plugins/environment-vars.html">Keeping Secrets</a></li> <li><a href="../plugins/optimising-ci-times.html">Optimise CI</a></li> <li><a href="../plugins/pre-compiling-dependencies.html">Pre-compiling dependencies</a></li> <li><a href="../plugins/using-pods-for-closed-source-libs.html">Packaging Closed Source SDKs</a></li> </ul> </div> <div class="col-lg-3 col-sm-3 col-xs-6 footer-index"> <h3><a href="../contributing/index.html">Contributing</a></h3> <ul> <li><a href="../contributing/contribute-to-cocoapods.html">How to Contribute</a></li> <li><a href="../contributing/components.html">Core Components</a></li> <li><a href="../contributing/dev-environment.html">Setting up for Development</a></li> <li><a href="../contributing/release-process.html">Release Process</a></li> <li><a href="../contributing/tickets-handling.html">Ticket handling</a></li> </ul> </div> <div class="clearfix visible-xs"></div> <div class="clearfix"></div> <div class="col-xs-12 footer-index"> <h3> <a href="/reference.html">Reference</a> </h3> <ul> <li class="col-lg-3 col-sm-3 col-xs-6"><a href="/syntax/podfile.html">Podfile Syntax</a></li> <li class="col-lg-3 col-sm-3 col-xs-6"><a href="/syntax/podspec.html">Podspec Syntax</a></li> <li class="col-lg-3 col-sm-3 col-xs-6"><a href="/terminal/commands.html">Command-line Reference</a></li> </ul> </div> </div></section><footer class="page-footer"><section class="container"><div class="row"><article class="col-md-8 col-lg-8 col-sm-12 col-md-offset-2 col-lg-offset-2 col-xs-12"><h4>CocoaPods is a project from</h4> <p class="contributors"> <a href="https://twitter.com/dnkoutso">Dimitris Koutsogiorgas</a>, <a href="https://dani.builds.terrible.systems/">Danielle Lancashire</a>, <a href="https://github.com/amorde">Eric Amorde</a>, <a href="https://orta.io">Orta Therox</a>, <a href="https://github.com/paulb777">Paul Beusterien</a>, <a href="https://segiddins.me">Samuel Giddins</a>, and <a href="https://cocoapods.org/about#team">The CocoaPods Dev Team</a> with contributions from <a href="https://github.com/CocoaPods/Specs/graphs/contributors">many, many others</a>.</p> <h4>Lovingly sponsored by</h4> <p class="sponsors"><a href="http://artsy.net">Artsy</a>, <a href="http://www.usebutton.com">Button</a>, <a href="http://www.capitalone.io">Capital One</a>, <a href="https://circleci.com">CircleCI</a>, <a href="http://discontinuity.eu">Discontinuity</a>, <a href="https://www.emergetools.com">Emerge Tools</a>, <a href="http://www.fngtps.com">Fingertips</a>, <a href="https://developers.google.com">Google</a>, <a href="https://www.heroku.com">Heroku</a>, <a href="https://www.jsdelivr.com">jsDelivr</a>, <a href="https://realm.io">Realm</a>, <a href="https://pspdfkit.com/">PSPDFKit</a>, <a href="http://www.rubymotion.com">RubyMotion</a>, <a href="https://www.sauspiel.de">Sauspiel</a>, <a href="https://www.slack.com">Slack</a>, <a href="https://www.soundcloud.com">SoundCloud</a>, <a href="https://www.stripe.com">Stripe</a>, <a href="https://www.squareup.com">Square</a>, and <a href="http://www.technologyastronauts.ch">Technology Astronauts</a>.</p></article></div></section></footer><footer class="footer-links"><section class="container"><div class="row"><article class="col-md-8 col-lg-8 col-sm-12 col-md-offset-2 col-lg-offset-2 col-xs-12"><a class="cocoapods-small-logo" href="https://cocoapods.org"></a><ul> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://guides.cocoapods.org/using/troubleshooting.html">Support</a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://github.com/CocoaPods/CocoaPods">GitHub Repo</a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://status.cocoapods.org">Web Properties Status</a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://twitter.com/CocoaPods">@CocoaPods</a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="http://groups.google.com/group/cocoapods">Mailing List</a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://cocoapods.org/about"><span class="visible-lg-span">CocoaPods</span> Dev Team</a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://guides.cocoapods.org/syntax/podfile.html">Podfile Doc<span class="hidden-lg-span">s</span><span class="visible-lg-span">umentation</span></a></li> <li class="col-md-3 col-sm-3 col-xs-6"><a href="https://cocoapods.org/legal">Legal / Conduct</a></li> </ul></article></div></section></footer> </body> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-29866548-4', 'cocoapods.org'); ga('send', 'pageview');</script> </html>

Pages: 1 2 3 4 5 6 7 8 9 10