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