In this lesson, let's take a minute to talk about why CocoaPods is useful and discuss some alternatives 1
to CocoaPods. CocoaPods is something called a Package Dependency Manager. 2
Now, what is a Package Dependency Manager anyways? 3
Well, it's kind of like the manager in a factory. 4
The Package Dependency Manager will monitor for changes to all of the packages that you've added to 5
your project. 6
So that means if you had, say, 10 different packages that you've added to your project, in addition to the 7
CLTypingLabel, when the authors of those packages update their code, you don't have to manually go 8
to GitHub, see what the changes are, and then add those bits of changed code to your project. 9
And you don't have to actively monitor what it is that they're doing. 10
Instead, what you'll be able to do is you'll be able to navigate into your project, say for example, 11
our FlashChat iOS13, and run a command called pod update. And this will go out there and fetch all the 12
latest versions of all the pods that you were using. Say, if the CLTypingLabel got updated from 0.4.0 13
to 0 5.0, then it will automatically pull the latest versions in and incorporate it into your project. 14
Saving you lots of stress, and so that you keep your hair instead of pulling it out. 15
Now, it's important to remember that CocoaPods is not the only player in this sector. 16
So in addition to CocoaPods, the other ones that you might hear of along the way are something called 17
Carthage, as well as the Swift Package Manager. 18
In terms of Carthage, I find the installation and updating of dependencies super painful. 19
So it's something I really don't like that much and I don't recommend it. 20
The Swift Package Manager is something that only became more useful recently because of a number of 21
updates that Apple has made. And in fact, the idea with the Swift Package Manager is you should be able 22
to go to File, Swift Packages, Add Package Dependency, so let's select our project, and then you should be 23
able to search or enter a package repository URL. 24
So, for example, Alamofire is one of the biggest third party modules out there that lots of people use. 25
You can see just by how many stars it has. 26
And this is something that we can install using either CocoaPods Carthage or Swift Package Manager. 27
And all you would have to do is to select this URL, copy and paste it in here, and then hit Next, 28
and it will go ahead and install it for you. 29
But, but, but a big word of warning here is that at the moment, as it is right now in 2019, end of 2019, 30
sort of going on to November, when I'm recording this, the Swift Package Manager really does not play 31
nicely with CocoaPods which would be fine if we were only going to use this Swift Package Manager, right? 32
It's Apple's tools. 33
It's the native implementation. 34
So what's wrong with that? 35
Well, the problem is that there's very few developers at the moment who are able to support the Swift 36
Package Manager. And the way that you can tell is when you go onto a GitHub repository for one of these 37
third party Swift libraries. 38
If you take a look at this list of files, if you see something called something.podspec, it means 39
it probably supports CocoaPods. And if you see package.swift, then it means it supports the Swift 40
Package Manager or the SPD. But notice how things like the one that we use just now, CLTypingLabel, 41
well, that doesn't have that file, 42
right? 43
So it doesn't support it. 44
And even Firebase which we're gonna be using heavily and it's something that's developed by Google has 45
a lot of manpower behind it. 46
You'll notice, actually, it doesn't support a Swift Package Manager either. 47
This might change in the coming days when SP deals with package manager becomes more popular. But, effectively, 48
when I make a decision to see which particular package manager I use, it all really depends on Developer 49
Love, right? 50
If developers like distributing their third party code using a particular package manager which at the 51
moment, CocoaPods seems to win out, then that's probably the one that I'm going to be using because it 52
means I get access to a much wider array of different third party libraries. 53
So my recommendation at the moment is to stick with CocoaPods. 54
And if this changes, I'll be sure to let you guys know through an educational announcement. 55
So now that we've installed CocoaPods and we've learned all about how to use it, let's go ahead and 56
put it into practice by adding Firebase to our project. 57
So for all of that and more, I'll see you on the next lesson.