All right. 1
So in this lesson, I'm going to talk about Third Party Libraries, what they are, and how to use them using 2
something called CocoaPods. 3
What exactly are third party libraries anyways? 4
Well, let's imagine that you have an assignment where you have to write an essay about volcanoes. And, yeah, 5
you know a little bit about volcanoes already, you know that they're kind of pointy, and they're kind of hot, 6
and sometimes they emit a lot of gas, which could probably be said of my roommate, too, but you 7
might not know that, for example, volcanoes are named after the Roman god Vulcan, which is this blacksmith 8
dude, who's really good with fire, or the fact that maybe the largest volcano is actually on Mars and 9
it's something like 370 miles across which is like about six hundred kilometers in 10
diameter. 11
So where would you find these kind of things out? 12
Well, you might have gone to an actual library, right, and you could take out a book on volcanoes. 13
So between this book and your knowledge, you can actually cobble together this essay. 14
Now, I'm not saying this is how you should write essays, copy things from books or from Wikipedia. 15
But, essentially, a lot of times, you don't have the knowledge or the capabilities or the time to be able to 16
completely create something by yourself. 17
So in the case of the app, you can actually combine your code with third party library code that other 18
people have created, and you're able to leverage these third party libraries of code which contain individual 19
modules for specific purposes, 20
say, for example, an animation library that helps you animate the components of your app, or a Lintel library 21
which helps you fix and improve your Swift code, or something like Firebase which we're going to be using 22
a little bit later on in order to work with the databases on Firebase and in Cloud storage. 23
So, essentially, you end up standing on the shoulders of giants saving yourself lots of time and, also, 24
occasionally being able to do things you might not have otherwise known how to do. 25
So let's go ahead and see this in action. 26
Now, the first thing I want you to do is to actually close down the project that you're currently working 27
with. And in your browser, head over to cocoapods.org. 28
This is the tool that we're going to be using to search for and incorporate some third party libraries 29
into our project. 30
Now, when you go to cocoapods.org, there is a search bar which, admittedly, sometimes it doesn't work 31
that well, but most of the time, as long as the server's up and running, you should be able to type stuff 32
in here. 33
Say, for example, if I wanted to find a library that helps me create a typing animation, then I could search 34
for the word "typing," 35
and you can see a whole bunch of different libraries that we can add. 36
So this top one which is a UILabel with character by character typing animation written in Swift, 37
so that sounds pretty good, 38
that sounds pretty much like exactly what we want, 39
right? 40
So if you go ahead and click on it, one of the key things you have to do is judge whether if these libraries 41
are well maintained and if they're updated regularly. 42
So you can see some of this information over here. 43
You can see that the builds are passing. 44
So these are automatic builds and tests that are run on this library of code. And you can also see when 45
it was last updated. 46
So you can see this one was last updated in October 2019. 47
And right now, it's October 2019 as I'm recording this, 48
so that's pretty good. 49
Now, the other thing that you can see is when you go ahead and click on this link here with the little 50
GitHub Octocat. It takes you to where that code is hosted. 51
So, it's usually going to be on GitHub. 52
And here you can actually look through the code that enables this capability. 53
For example, if we go into Pod and then we go into Classes, we can see that this is pretty much the 54
class that's enabling the functionality. 55
So it basically subclasses our UILabel and adds a whole bunch of capabilities to it in order for it 56
to animate 57
with that typing animation. 58
So when you're on GitHub, a quality indicator or at least a popularity indicator is by looking at the 59
number of people who have started this project or repository. 60
So this one has 65. 61
And if you were to go back and compare some of the competing ones which also have this functionality 62
and look at how many stars they have, then you'll be able to roughly judge how many people actually have 63
used this, and how many people are interested in it as a sort of proxy for quality. 64
So, now that we found this pod that we'd like to enable in our project to get something like this going 65
on, how do we actually do it? 66
Well, usually on the read-me page, 67
so on the main page of the project that you get linked to from CocoaPods, you'll get a section on installation. 68
And you can see that there's usually a whole bunch of different options. 69
You can either do it manually by copy and pasting this file into your Xcode project. And I don't recommend 70
doing it like this because there's usually a lot of updates that happen to Swift and to Xcode, and that 71
means that you're going to be responsible for maintaining the code afterwards if you want to add it 72
manually. 73
Alternatively, you would have to monitor for changes in this repository and see when the author updates 74
their code, and then copy and pasting it again whenever that happens. 75
That's really, really tedious. 76
So instead, we're gonna be using this great tool called CocoaPods. In the next lesson, 77
I'm gonna show you how to install CocoaPods onto your Mac.