0
1
00:00:00,620 --> 00:00:07,340
Now that you've successfully installed CocoaPods, it's time to install your first pod for your project.
1

2
00:00:07,340 --> 00:00:12,980
In this lesson, I'll show you how to work with a pod file and how to generate an .xcworkspace project
2

3
00:00:13,040 --> 00:00:15,610
that include a CocoaPod.
3

4
00:00:15,680 --> 00:00:17,870
You should still have your Terminal up and running.
4

5
00:00:17,870 --> 00:00:19,830
If not, go ahead and open it up.
5

6
00:00:19,850 --> 00:00:24,740
The first step is to navigate to the directory where our project lives.
6

7
00:00:24,740 --> 00:00:27,450
So let's first locate it inside our Finder.
7

8
00:00:27,470 --> 00:00:29,300
So in my case, it's pretty easy.
8

9
00:00:29,330 --> 00:00:33,500
The project folder is just nested in my desktop folder.
9

10
00:00:33,980 --> 00:00:40,640
So what I want you to do is notice how this is the containing folder for our Xcode project.
10

11
00:00:40,640 --> 00:00:46,760
So you want to select this parent folder. And then inside Terminal, you're going to write "cd" for change directory,
11

12
00:00:46,760 --> 00:00:52,730
which effectively means navigate somewhere else, and then you're going to click and drag this
12

13
00:00:52,730 --> 00:01:00,770
folder into the Terminal so that it puts the entire pathway that is required to get hold of that 
13

14
00:01:00,770 --> 00:01:01,100
FlashChat iO13
14

15
00:01:01,090 --> 00:01:04,830
project, and then we're going to hit enter.
15

16
00:01:05,190 --> 00:01:12,010
And notice how here is now changed to show that we're currently located inside this folder.
16

17
00:01:12,260 --> 00:01:18,410
So you can see the Terminal, the command line, is almost like a parallel system to this graphical user
17

18
00:01:18,410 --> 00:01:24,650
interface which is the Finder, and we can pretty much do exactly the same things that we can do
18

19
00:01:24,650 --> 00:01:25,150
in Finder.
19

20
00:01:25,250 --> 00:01:28,970
For example, when we're inside Flash-Chat-iOS13,
20

21
00:01:28,970 --> 00:01:36,140
we see it at the top of our Finder, and in Terminal, we see it right after the name of our computer.
21

22
00:01:36,170 --> 00:01:44,090
So, now when we're here if we want to see what's inside this folder,  we can use a "ls" command which is going
22

23
00:01:44,090 --> 00:01:47,380
to list all of the things that this folder contains,
23

24
00:01:47,390 --> 00:01:56,820
same as over here. Now, what we want to do is inside this Flash-Chat-iOS13 parent folder, so the
24

25
00:01:56,820 --> 00:02:03,260
one that contains the Xcode project, not this one which is parallel to the Xcode project.
25

26
00:02:03,420 --> 00:02:10,320
It's here that we want to run the command "pod init." And what this will do is it will initialize a new
26

27
00:02:10,320 --> 00:02:11,340
pod file.
27

28
00:02:11,340 --> 00:02:18,500
So once I hit enter, you'll see that pod file appear right here. And then we're going to open this pod file.
28

29
00:02:18,510 --> 00:02:20,770
Now, you can do that in a number of ways.
29

30
00:02:20,850 --> 00:02:29,250
The easiest way is to simply right-click, and then click Open With, and then select Other, and then we're
30

31
00:02:29,250 --> 00:02:37,600
going to find Xcode in here, and select Xcode, and then select as Always Open With this application.
31

32
00:02:37,770 --> 00:02:43,900
Go ahead and click Open and it should now open that pod file using Xcode.
32

33
00:02:43,920 --> 00:02:51,960
So, now we have to format this pod file, so that we actually add the pod that we're interested in.
33

34
00:02:51,960 --> 00:02:53,840
And to get some practice with CocoaPods,
34

35
00:02:53,850 --> 00:02:57,580
the part that we're going to add is the CLTypingLabel.
35

36
00:02:57,630 --> 00:03:04,110
This pod contains a bunch of code that allows us to do text animations in our project. But let's first
36

37
00:03:04,110 --> 00:03:06,270
turn our attention back to our pod file.
37

38
00:03:06,930 --> 00:03:14,080
So first, some formatting. It wants us to define a global platform for our project.
38

39
00:03:14,520 --> 00:03:19,560
So notice how this code file actually looks quite different from what we're used to seeing.
39

40
00:03:19,560 --> 00:03:22,920
This is because this is actually written in a different language.
40

41
00:03:22,920 --> 00:03:30,240
This is actually a Ruby file. And in Ruby, instead of having comments like this, they have comments created
41

42
00:03:30,240 --> 00:03:31,560
using the pound sign.
42

43
00:03:32,160 --> 00:03:36,870
So, therefore, this line and this line, they're all commented out.
43

44
00:03:36,870 --> 00:03:39,270
So let's go ahead and uncomment
44

45
00:03:39,270 --> 00:03:47,340
the next line by deleting the pound sign here to define a global platform. And what this platform does is
45

46
00:03:47,340 --> 00:03:50,190
it allows you to define the minimum
46

47
00:03:50,190 --> 00:03:53,730
iOS version that you want your app to support.
47

48
00:03:53,730 --> 00:03:59,700
So in this case, it's saying the iOS platform 9.0 or above.
48

49
00:03:59,700 --> 00:04:07,470
So you can if you wanted to, say, that will actually my app is going to only be run on phones which are
49

50
00:04:07,470 --> 00:04:14,580
running OS 13 or later. And in certain cases, we're going to see a little bit later on. Certain pods or
50

51
00:04:14,580 --> 00:04:20,280
certain third party libraries have a much higher requirement because they're using more recent features
51

52
00:04:20,280 --> 00:04:29,130
of iOS or of Swift. In our case, we're going to leave it as 9.0 and I'm going to delete this
52

53
00:04:29,190 --> 00:04:30,410
top comment as well.
53

54
00:04:31,190 --> 00:04:38,400
And then down here, we're going to delete this other comment. So we now have a single comment that says,
54

55
00:04:38,400 --> 00:04:39,780
"Pods for Flash Chat iOS13."
55

56
00:04:39,810 --> 00:04:46,200
And between that line and end is where we're going to add all of our pods.
56

57
00:04:46,350 --> 00:04:55,110
So if we go back to the CLTypingLabel page on CocoaPods, you can see that it tells you to add this
57

58
00:04:55,110 --> 00:05:03,500
line to your pod file. So let's copy that and paste it right here, and then go ahead and hit save.
58

59
00:05:03,510 --> 00:05:10,260
So, now that our pod file is saved, we can close down this project and go back to our Terminal app.
59

60
00:05:10,620 --> 00:05:17,110
And here, we're going to run the command pod install, and then hit enter.
60

61
00:05:17,130 --> 00:05:25,970
So this is going to go and fetch the pod file from CocoaPods and install it into our project.
61

62
00:05:26,010 --> 00:05:28,180
Now, here's an important part.
62

63
00:05:28,200 --> 00:05:36,120
Notice how it tells you to close any current Xcode sessions and use the file: 
63

64
00:05:36,390 --> 00:05:40,500
Flash Chat iOS13.xcworkspace for this project from now on.
64

65
00:05:40,500 --> 00:05:47,340
As long as you don't see any problems here, then we're ready to go ahead and work with this new file.
65

66
00:05:47,340 --> 00:05:53,850
So if we head back over to our project, Flash-Chat-iOS13, you can see that there's some new files that
66

67
00:05:53,850 --> 00:05:58,280
have been added here. And this new file that's been generated,
67

68
00:05:58,290 --> 00:06:05,370
Flash Chat iOS13.xcworkspace is what we're going to be working on from now on.
68

69
00:06:05,370 --> 00:06:14,580
And the big difference is that our original Xcode project has a blue icon, and this workspace that contains
69

70
00:06:14,730 --> 00:06:17,760
our pod files has a white background.
70

71
00:06:17,790 --> 00:06:25,140
So make sure that you're actually now using exclusively this file. And if you get some problems down
71

72
00:06:25,140 --> 00:06:28,220
the line, such as strange errors that you can't solve,
72

73
00:06:28,290 --> 00:06:34,560
just check to make sure that you haven't accidentally used this blue file, instead of the xcworkspace
73

74
00:06:34,560 --> 00:06:35,970
or the white file.
74

75
00:06:35,970 --> 00:06:39,620
So let's go ahead and double click on this white file and then open it up.
75

76
00:06:41,120 --> 00:06:48,440
And you can see that you have the pods and you also have your original FlashChats project.
76

77
00:06:48,670 --> 00:06:55,540
Now, if I expand this Flash Chat iOS13 folder, you can see that we've still got the same files as we had
77

78
00:06:55,540 --> 00:07:02,230
from before. But there are some differences with the xcworkspace project. At the bottom of the project
78

79
00:07:02,230 --> 00:07:02,830
pane,
79

80
00:07:02,830 --> 00:07:08,890
you can see the pods that we've added and you can also see the pod file that we've edited. In the next
80

81
00:07:08,890 --> 00:07:09,360
lesson,
81

82
00:07:09,370 --> 00:07:14,710
I'll show you some potential problems with pod installation. And in the process, you'll get a deeper understanding
82

83
00:07:14,770 --> 00:07:18,700
of how pod versioning works and how pods can be updated.
83

84
00:07:18,700 --> 00:07:20,080
So, hopefully, I'll see you there.
