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