All right. 1
In this lesson, we're going to be installing CocoaPods using something called the Terminal. 2
Now, the installation process requires issuing two commands into the Terminal: sudo gem install cocoapods 3
and pod setup. 4
The only other thing you need is a stable internet connection and a little bit of patience. 5
So if we go to the CocoaPods homepage, there's a handy Getting Started Guide, and it tells you, "What is 6
CocoaPods." 7
How do you install CocoaPods? 8
And a really good resource I recommend is taking a look at this video that Google has created as a part 9
of "The Route 85 Show" which is a bunch of resources that they've compiled or tutorials for iOS development 10
which is kind of strange coming from Google Developers. 11
Now, admittedly, this video has some pretty cheesy jokes but, you know, if you just bear with it, there's 12
actually quite a lot of good information that they are giving you on how CocoaPods work, what it is, 13
and how to install and use it. 14
Now, I'm also going to walk you through how to install CocoaPods for the first time. 15
The first thing to do is to go ahead and open up something called Terminal. 16
Now, if you have a favorite Terminal, then go ahead and use that. 17
But for everybody else who's never heard of what a Terminal is, then simply just click on the spotlight 18
icon and search for Terminal. Terminal is an application that gets installed by default along with 19
macOS, 20
so you should all have it. 21
So double click to open it. And at this point, you should see a window appear that looks like this or 22
like this, or like this. 23
The important thing to notice is that no matter how the Terminal looks, it always has something called 24
a prompt. The prompt will look like a dollar sign or percentage sign. And it's after this prompt that 25
you can issue commands to your computer. 26
Now, if you've updated from an older operating system to macOS Catalina, then you might be greeted with 27
a message like this. If you don't see this message, then don't worry, 28
simply skip ahead to the next timestamp. 29
But if you do see this message, then you can follow along with me. 30
The reason why we're getting this message is because Apple has updated the shell in the Terminal to 31
something called zsh. 32
So all that you have to do to get rid of these errors and to use this latest version is to simply copy 33
this line. 34
So in between the single quotes, not including the single quotes, hit command C, and then go ahead and 35
paste it down here with command V. 36
And what this line of code will do once you hit enter is it will simply change the shell from what used 37
to be bash to this new thing called zsh. 38
So it's going to ask you for your password and you should be logged in in the admin account to do this. 39
If not, go ahead and log out and log back in as the admin account for your computer. 40
So I'm just gonna go ahead and type my password, and notice how when you're in Terminal, when you're typing, 41
it doesn't show anything, it doesn't show what you're typing, it doesn't show little sort of asterisks. 42
You have to make sure that you're actually typing the right thing. And then hit enter. 43
And if you've typed in the right password, it will just go ahead and allow you to continue. 44
If you haven't, it'll tell you that you've typed in the wrong password, and you have to try again. 45
So this blind typing takes a little bit of work to get used to, but I'm sure you'll get there eventually. 46
And now I'm going to write the command clear in here to give me a blank slate to work with. 47
There are only two commands that we need to issue in Terminal to be able to install CocoaPods. 48
And the first one is sudo gem install cocoapods. 49
So make sure that you're spelling it exactly the same as you see here. 50
If we head back over to the CocoaPods Guide, you can see that we need to use this line of commands after 51
the dollar sign which is the prompt. 52
And back in our Terminal, that's what I'm going to write sudo gem install cocoapods, and then hit enter. 53
Now, it's going to ask you for your password. 54
And this is the password that you're using to log in to your current account. 55
And remember that that account needs to be an admin account. 56
It needs to have admin permissions. Because, otherwise, even if you enter the password, it's not going to 57
work. 58
So just like when you install big applications onto your Mac, you always need to have an admin account 59
to do that. 60
So if you're not logged in as the admin, make sure that you log out and log in with the admin account 61
before you proceed. 62
So, now when we write our password, notice how it's actually not going to show you any asterisks or any 63
indication that you're typing at all, 64
so you have to do it blind. 65
So let me just put in my password and you'll see that nothing has happened. 66
But once you're sure you've typed out your entire password, then go ahead and hit enter. 67
Now, as long as you've got your password correct, then it should start fetching and installing CocoaPods. 68
Now, depending on your internet speed, this can take anywhere between just now you saw a couple of seconds 69
to 5, to 10 minutes. 70
So just be patient and wait until you see your prompt again, and you see this percentage sign, as well 71
as a flashing cursor which tells me that it's ready to take new commands again, 72
so that means it's done with the previous thing that you asked it to do. 73
So be patient and just let it work its magic. 74
So, now that we've installed CocoaPods and we've got nine gems installed, we've got no errors reported 75
anywhere, 76
then we're ready to proceed on to the next step. And step two involves the command pod setup. And at the 77
end, we're going to add the flag, 78
--verbose. 79
And what this does is it's going to pull down what's called the master repository from CocoaPods which 80
lists all of the available CocoaPods, the same ones that you can find in search on cocoapods.org, 81
as well as their latest versions and how to get hold of them. 82
So this process can take quite a while even longer than the previous step. 83
And that's why at the end, we've added this flag --verbose, 84
so that it tells us what's going on 85
each step of the process, so it doesn't look like it's just stuck. 86
But word of warning, this is gonna take a while, 87
and, again, it requires pretty reliable internet. 88
And if it fails, just try it again until you get a success message, and you see your prompt again. 89
And that completes the setup. 90
There's only one thing left to do. 91
Check if everything is actually working and if installation was successful. 92
So to check to see if your setup properly with CocoaPods, 93
I want you to enter the command. So after your prompt, 94
be it a dollar sign or a percentage sign, 95
go ahead and type pod --version. 96
So this is two hyphens and then version, and there should be a space between the pod and the first dash, 97
and then go ahead and hit enter. 98
Now, at the time of recording, my CocoaPod version is currently 1.8.4. 99
So you should see a version like this or, hopefully, it'll be higher for you. 100
So it might be1.8.5 or 1.9.something. But as long as you see this 101
after typing the pod --version command, then it means that you've got CocoaPods successfully 102
installed and set up, and you're ready to go. 103
But what if you see an error message instead, say, it doesn't recognize the command pod or something like 104
that, 105
well, then I recommend trying the steps in the lesson again to install and set up CocoaPods. 106
And if that doesn't help, then head over to the troubleshooting guide on the CocoaPods website. The troubleshooting 107
page will show you some of the common problems and the possible fixes you can do. 108
But in most cases, they should go through successfully without you needing to do anything else, 109
although it'll just take some time. Now, with the setup out of the way, we can harness the true power of CocoaPods. 110
So for all of that and more, I'll see you on the next lesson.