Skip to content
This repository was archived by the owner on Aug 14, 2021. It is now read-only.

Commit 88d0275

Browse files
committed
Track original version
0 parents  commit 88d0275

File tree

307 files changed

+27841
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+27841
-0
lines changed

2013/01/05/cocoapods.html

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!DOCTYPE html><html lang="en"><head><title>CocoaPods! | mokacoding</title><meta name="description" content="A brief introduction to CocoaPods, the Objective-C dependencies manager."><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"><!-- Canonical URL--><link rel="canonical" href="https://mokacoding.com/blog/cocoapods/"><!-- Open Graph meta tags--><meta property="og:title" content="CocoaPods!"><meta property="og:description" content="A brief introduction to CocoaPods, the Objective-C dependencies manager."><meta property="og:url" content="https://mokacoding.com/blog/cocoapods/"><meta property="og:type" content="article"><meta property="og:site_name" content="mokacoding"><meta property="og:image" content="https://s3.amazonaws.com/mokacoding/mokacoding_og_image.jpg"><!-- Twitter meta tags--><meta property="twitter:card" content="summary"><meta property="twitter:title" content="CocoaPods!"><meta property="twitter:site" content="@mokacoding"><meta property="twitter:creator" content="@mokagio"><!-- Stylesheets--><link href="/css/griddy.css" rel="stylesheet"><link href="/css/style.css" rel="stylesheet"><link href="/css/font-awesome.min.css" rel="stylesheet"><link href="/css/zenburn.css" rel="stylesheet"><!-- FavIcon--><!-- Thanks to https://www.favicon-generator.org/ & https://html2jade.org/--><link rel="apple-touch-icon" sizes="57x57" href="https://s3.amazonaws.com/mokacoding/apple-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="https://s3.amazonaws.com/mokacoding/apple-icon-60x60.png"><link rel="apple-touch-icon" sizes="72x72" href="https://s3.amazonaws.com/mokacoding/apple-icon-72x72.png"><link rel="apple-touch-icon" sizes="76x76" href="https://s3.amazonaws.com/mokacoding/apple-icon-76x76.png"><link rel="apple-touch-icon" sizes="114x114" href="https://s3.amazonaws.com/mokacoding/apple-icon-114x114.png"><link rel="apple-touch-icon" sizes="120x120" href="https://s3.amazonaws.com/mokacoding/apple-icon-120x120.png"><link rel="apple-touch-icon" sizes="144x144" href="https://s3.amazonaws.com/mokacoding/apple-icon-144x144.png"><link rel="apple-touch-icon" sizes="152x152" href="https://s3.amazonaws.com/mokacoding/apple-icon-152x152.png"><link rel="apple-touch-icon" sizes="180x180" href="https://s3.amazonaws.com/mokacoding/apple-icon-180x180.png"><link rel="icon" type="image/png" sizes="192x192" href="https://s3.amazonaws.com/mokacoding/android-icon-192x192.png"><link rel="icon" type="image/png" sizes="32x32" href="https://s3.amazonaws.com/mokacoding/favicon-32x32.png"><link rel="icon" type="image/png" sizes="96x96" href="https://s3.amazonaws.com/mokacoding/favicon-96x96.png"><link rel="icon" type="image/png" sizes="16x16" href="https://s3.amazonaws.com/mokacoding/favicon-16x16.png"><link rel="manifest" href="https://s3.amazonaws.com/mokacoding/manifest.json"><meta name="msapplication-TileColor" content="#ffffff"><meta name="msapplication-TileImage" content="https://s3.amazonaws.com/mokacoding/ms-icon-144x144.png"><meta name="theme-color" content="#ffffff"><!-- SumoMe--><script src="//load.sumome.com/" data-sumo-site-id="dd80959300db03e20c8bc3dd899f1424fd764d261e6c3c41923c96482a270dba" async="async"></script></head><body><!-- Use this to render an extra header in special occasions--><div class="special-header"><div class="page"><div class="row-12"><div class="col-12"><p><!-- - Saving this for later and to avoid a `git revert`:markdown
2+
[What is your biggest struggle right now with building software?](https://goo.gl/forms/lCLlJd9hqCUYoTME2)--><p><a href="https://tddinswift.com?utm_source=mokacoding-site&amp;utm_campaign=coming-soon&amp;utm_medium=sticky-header">Avilable Now: <strong>Test-Driven Development in Swift with SwiftUI and Combine</strong></a></p>
3+
</p></div></div></div></div><div class="page"><div class="row-12"><div class="col-12 header"><h1 class="brand"><a href="/">mokacoding</a></h1><div class="punchline">unit and acceptance testing, automation, productivity</div><div class="links"><a href="/archive.html">Archive</a><a href="/tags.html">Tags</a><a href="https://gio.codes">About</a><a href="#subscribe">Subscribe</a><a href="/feed.xml"><i class="fa fa-rss"></i></a></div></div><div class="col-12"><div class="post-container"><h2 class="post-title"><a href="/blog/cocoapods">CocoaPods!</a></h2><p class="post-meta"><span class="post-date">Sat Jan 05 2013&nbsp;</span><a href="/tag/CocoaPods/index.html" class="post-tag">-CocoaPods</a><a href="/tag/iOS/index.html" class="post-tag">-iOS</a></p><div class="post"><h2 id="what-is-cocoapods-">What is CocoaPods?</h2>
4+
<blockquote>
5+
<p>CocoaPods: The best way to manage library dependencies in Objective-C projects.</p></p>
6+
</blockquote>
7+
<p>If you&#39;re familiar with Ruby on Rails, it&#39;s the same thing as <a href="http://gembundler.com/">Bundler</a>, or it&#39;s lame copy attempt for Symfony 2, <a href="http://getcomposer.org/">Composer</a>.</p>
8+
<p>If you&#39;re not, and you haven&#39;t sorted it out from the quote above, CocoaPods is a tool that&#39;s let us manage our libraries and their dependencies in our Objective-C projects. This means:</p>
9+
<ol>
10+
<li>No more wasted time downloading all the libraries the one we want to use depends on.</li>
11+
<li>Smart and safe version management, specially when we&#39;re working on a project with other people, which is 90% of the time.</li>
12+
</ol>
13+
<p>To <em>&quot;get my hands dirty&quot;</em> with CocoaPods I made this little project called <a href="https://github.com/mokagio/justninegags">JustNineGags</a>, feel free to check it out on GitHub.</p>
14+
<h2 id="why-should-i-use-it-">Why should I use it?</h2>
15+
<p>Because it&#39;s awesome! It makes development faster and easier, and also safer! It easier to work in teams and keep the libraries versions even. Should I go on? Ok! Just think about this: you won&#39;t download and move in your project a library anymore, <code>pod</code> will do it all for you!</p>
16+
17+
<h2 id="installing-cocoapods">Installing CocoaPods</h2>
18+
<p>Installing CocoaPods is as simple as installing all the other Ruby Gems, I shouldn&#39;t even writing this, as what&#39;s written in the <a href="http://cocoapods.org/#install">install section</a> is more than enough, anyway:</p>
19+
20+
<pre><code class="">gem <span class="hljs-keyword">install</span> cocoapods
21+
</code></pre><p>Once the installation is completed run:</p>
22+
23+
<pre><code class="">pod <span class="hljs-built_in">setup</span>
24+
</code></pre><p>This will, guess what, setup everything CocoaPods needs on your system. You should see an output like this:</p>
25+
26+
<pre><code class="">Setting <span class="hljs-keyword">up</span> CocoaPods master repo
27+
Cloning spec repo <span class="hljs-string">&#x27;master&#x27;</span> from <span class="hljs-string">&#x27;&lt;a href=&#x27;</span>http<span class="hljs-variable">s:</span>//github.<span class="hljs-keyword">com</span>/CocoaPods/Specs.git<span class="hljs-string">&#x27;&gt;https://github.com/CocoaPods/Specs.git&lt;/a&gt;&#x27;</span> (branch <span class="hljs-string">&#x27;master&#x27;</span>)
28+
Setup completed (<span class="hljs-keyword">read</span>-<span class="hljs-keyword">only</span> access)
29+
</code></pre><p>Done! :)</p>
30+
31+
<p><em>You should avoid using <code>sudo</code> otherwise everything else you&#39;ll do with <code>pod</code> will need to use <code>sudo</code> as well. And this mean that the folders and file that are gonna be created will be owend by <code>root</code> instead that by you.</em></p>
32+
33+
<h2>Using CocoaPods</h2>
34+
35+
<p>Again, everything written on the <a href="http://cocoapods.org/#get_started">website</a> is pretty straightforward.</p>
36+
37+
<p>Go in the root folder of your Objective-C project and create a file named <code>Podfile</code>, with whatever editor you like. We&#39;ll use this file to list all the libraries, <em>pods</em>, we need in the project. The JustNineGags <code>Podfile</code> content is:</p>
38+
39+
<pre><code class=" hljs ruby">platform <span class="hljs-symbol">:ios</span>
40+
pod <span class="hljs-string">&#x27;MBProgressHUD&#x27;</span>, <span class="hljs-string">&#x27;~&gt; 0.5&#x27;</span>
41+
pod <span class="hljs-string">&#x27;Reachability&#x27;</span>, <span class="hljs-string">&#x27;~&gt; 3.1.0&#x27;</span>
42+
</code></pre>
43+
<h3>Adding a Pod</h3>
44+
45+
<p>As you can see adding a Pod is really easy, just go on <a href="http://cocoapods.org">CocoaPods website</a>, look for the it, and then add it to the <code>Podfile</code> using it&#39;s name and the version you need.</p>
46+
47+
<h3>Installing the Pods</h3>
48+
49+
<p>Right now we&#39;ve told CocoaPods the Pods we need but they aren&#39;t yet in out project. So let&#39;s run</p>
50+
51+
<pre><code class="">pod <span class="hljs-keyword">install</span>
52+
</code></pre><p>This will download all the libraries we&#39;ve asked for, and all their dependencies. Sweet!</p>
53+
54+
<p>The first time we run <code>pod install</code> something else will happen, a <code>Pods/</code> folder, a <code>Podfile.lock</code>, and a <code>YourProjectName.xcworkspace</code> will be created.</p>
55+
56+
<p><strong>Important!</strong> From now on remember to open your project through the <code>YourProjectName.xcworkspace</code> file, otherwise the pods won&#39;t be loaded by Xcode.</p>
57+
58+
<p>That&#39;s all folks! :)</p>
59+
60+
<h3>What should we track?</h3>
61+
62+
<p>Using CocoaPods adds some files and folders to our project, which of those should we track in our repo, and which should be left aside, adding them to the <code>.gitignore</code>? That of course assuming you&#39;re using git, and you definitely should. Let&#39;s have a look at the new stuff:</p>
63+
64+
<ul>
65+
<li><code>Podfile</code>, we definitely <b>need</b> this one, as all the pods we need are listed in it.</li>
66+
<li><code>Podfile.lock</code>, as for all the other library management systems, we <b>need</b> this one too, because it&#39;s used to assure all the developers are using the same versions of the pods and their dependencies.</li>
67+
<li><code>Pods/</code>, we <b>don&#39;t need</b> to track this folder, it&#39;s created by <code>pod install</code>, and all it&#39;s content is downloaded for us from other repos.</li>
68+
<li><code>YourProjectName.xcworkspace</code>, we <b>don&#39;t need</b> this one either, because it&#39;s generated by <code>pod install</code> too.</li>
69+
</ul>
70+
71+
<h2>What&#39;s coming next?</h2>
72+
73+
<p>How to setup our own pods. I&#39;ll probably write a little and simple Category to add other colors to the <code>UIColor</code> factories, stay tuned!</p>
74+
75+
<hr />
76+
77+
<h2>Update 2013-01-06</h2>
78+
79+
<p>To implement HTTP requests in <a href="https://github.com/mokagio/justninegags">JustNineGags</a> I used <code><a href="https://github.com/nfarina/webrequest">SMWebRequest</a></code> because I&#39;m too lazy to write everything by myself. <code>SMWebRequest</code> wasn&#39;t a Pod yet so I opened an <a href="https://github.com/nfarina/webrequest/issues/7">issue</a> asking good guy <a href="https://twitter.com/nfarina">nfarina</a> to add it. In less than 12 hours the Pod was added! :D</p>
80+
</div><div id="paginator" class="bottom-box clearfixed"><div class="col-6"><div><a href="/blog/cocoapods-how-to-create-your-own-pod"><<&nbsp;CocoaPods - How to create your own Pod</a></div></div><div class="col-6"></div></div><div id="subscribe" class="bottom-box"><!-- Begin Sendfox Signup Form -->
81+
<div id="sendfox_embed_signup">
82+
<h4 class="form_title">Want more of these posts?</h4>
83+
<p class="form_caption">Subscribe to receive new posts in your inbox.</p>
84+
<form method="post" action="https://sendfox.com/form/3ee4z3/10r4wg" class="sendfox-form" id="10r4wg" data-async="true" data-recaptcha="true">
85+
<p><input type="email" placeholder="Email" name="email" class="email" required /></p>
86+
<!-- no botz please -->
87+
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="a_password" tabindex="-1" value="" autocomplete="off" /></div>
88+
<div class="clear"><button type="submit">Sign me up</button></div>
89+
</form>
90+
<script src="https://sendfox.com/js/form.js"></script>
91+
</div>
92+
<!-- End Sendfox Signup Form -->
93+
</div><div class="bottom-box"><div id="disqus_thread"></div><script>var disqus_shortname = "mokacoding";
94+
// Neet do add the / at the end to maintain compatibility with previous version
95+
// of the blog that didn't define disqus_url, letting Disqus set it automatically
96+
// using window.location.href
97+
var disqus_url = "https://mokacoding.com/blog/cocoapods/";
98+
99+
(function() {
100+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
101+
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
102+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
103+
})();</script><noscript>Please enable JavaScript to view the<a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript></div></div></div></div><div class="row-12 footer"><div class="col-12"><h3><a href="/">mokacoding</a></h3></div><div id="copy" class="col-9"><p>Hi I&#39;m <a href="https://gio.codes">Gio</a> I write here semi-regularly on software testing and TDD, productivity, and iOS development.</p>
104+
<p><a href="mailto:gio+blog@mokacoding.com">Get in touch</a> if you&#39;re interested in working together.</p>
105+
</div><div id="links" class="col-3"><p><i class="fa fa-twitter"></i>&nbsp;<a href="https://twitter.com/mokagio">@mokagio</a></p><p><i class="fa fa-github"></i>&nbsp;<a href="https://github.com/mokagio">mokagio</a></p></div></div></div></body><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
106+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
107+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
108+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
109+
110+
ga('create', 'UA-43554041-1', 'auto');
111+
ga('send', 'pageview');
112+
</script><script>var toggle = function(elm){
113+
var y = elm.style && elm.style.display ? elm.style.display : 'block';
114+
if (y == 'block'){
115+
elm.style.opacity='0';
116+
setTimeout( function(){ elm.style.display = 'none'; }, 300 );
117+
}
118+
else {
119+
elm.style.display='block';
120+
setTimeout( function(){ elm.style.opacity = '1'; }, 10 );
121+
}
122+
}
123+
124+
document.getElementById('close').onclick = function(){
125+
toggle(document.getElementById('sticky-header'));
126+
toggle(document.getElementById('sticky-header-padding-hack'));
127+
}</script></html>

0 commit comments

Comments
 (0)