0 1 00:00:00,700 --> 00:00:01,100 All right. 1 2 00:00:01,130 --> 00:00:07,620 So now that we've successfully added the pod to our project and our project now build successfully, 2 3 00:00:07,620 --> 00:00:13,290 we can actually start making use of the CLTypingLabel module that we just added. 3 4 00:00:13,290 --> 00:00:17,550 So how would we find out what code to write to actually make use of this pod? 4 5 00:00:18,240 --> 00:00:24,900 Well, for that, we'll need to take a look at the documentation under the section Usage Instructions. 5 6 00:00:24,900 --> 00:00:31,500 You can either go back to the GitHub repository's read-me page or you can go back to the page that 6 7 00:00:31,500 --> 00:00:33,510 you saw on CocoaPods. 7 8 00:00:33,510 --> 00:00:40,260 But either way, we have a look at the usage section to see how we can actually use this library. 8 9 00:00:40,260 --> 00:00:48,020 So first, it tells us to change the class of a label from a default UILabel to a CLTypingLabel. 9 10 00:00:48,060 --> 00:00:52,810 So let's go ahead and do that in our Interface Builder as we can see here. 10 11 00:00:52,860 --> 00:00:59,220 So let's open up our Main.storyboard and I'm going to select the label that I want to animate which 11 12 00:00:59,220 --> 00:01:01,020 is this one, of course. 12 13 00:01:01,140 --> 00:01:07,050 And then when we open up the Attributes Inspector, we go over to the Identity Inspector, 13 14 00:01:07,140 --> 00:01:12,750 you can see that by default, it has a class of UILabel. But we're gonna click on the dropdown list and 14 15 00:01:12,750 --> 00:01:16,020 change it to a CLTypingLabel instead. 15 16 00:01:16,260 --> 00:01:23,340 And we're able to see this because we've successfully incorporated the CLTypingLabel module into 16 17 00:01:23,340 --> 00:01:26,330 our project using CocoaPods. 17 18 00:01:26,400 --> 00:01:30,450 So now that we've done step one, let's see what step two involves. 18 19 00:01:30,690 --> 00:01:38,340 Step two tells us to programmatically set a new string to its text property at runtime, 19 20 00:01:38,340 --> 00:01:41,490 and the animations would be triggered automatically. 20 21 00:01:41,580 --> 00:01:46,440 The English is not great here but we're getting a vague idea of what they want us to do. 21 22 00:01:46,470 --> 00:01:57,410 So, essentially, they want us to set the label to a new value when the view loads up. Let's go ahead and 22 23 00:01:57,410 --> 00:02:04,160 comment out all of this code that we've written and change this IBOutlet for our titleLabel which 23 24 00:02:04,220 --> 00:02:07,190 used to have a UILabel as the date type, 24 25 00:02:07,190 --> 00:02:11,270 but now it's actually a CLTypingLabel. 25 26 00:02:11,270 --> 00:02:17,470 And when you put this in, you'll see that it doesn't actually recognize what a CLTypingLabel is. 26 27 00:02:17,480 --> 00:02:24,380 So we have to remember to import the module that we installed using CocoaPods which was called 27 28 00:02:24,590 --> 00:02:31,190 CLTypingLabel. And once that's done and you hit command build, you should see that it now recognizes this 28 29 00:02:31,280 --> 00:02:38,690 data type. And inside of viewDidLoad, instead of all of these lines of code which you can keep if you 29 30 00:02:38,690 --> 00:02:44,630 want just as reference to how we use the for loop in here, but in my case, I'm going to try and keep things 30 31 00:02:44,630 --> 00:02:46,640 clean and I'm just going to delete it. 31 32 00:02:46,880 --> 00:02:51,080 And in our viewDidLoad, in order to trigger the animation, 32 33 00:02:51,080 --> 00:02:59,690 we're going to set the titleLabel.text to equal that string, which in our case was the emoji 33 34 00:02:59,690 --> 00:03:00,860 and the words "FlashChat." 34 35 00:03:01,370 --> 00:03:09,380 So, now by using this pod file, the CLTyping label which contains code that we didn't write, righ? 35 36 00:03:09,380 --> 00:03:17,330 This entire file, CLTyping Label.swift comes from this CocoaPod and it sets up the animation, and it 36 37 00:03:17,330 --> 00:03:24,210 basically does similar to what we got it to do, but perhaps, in a slightly better, more advanced way. 37 38 00:03:24,470 --> 00:03:30,920 And if we go back to our WelcomeViewController, all we have to do was change the class of the label that 38 39 00:03:30,920 --> 00:03:36,470 we want to animate, and then tell it what the text should be that should be typed into it. 39 40 00:03:36,980 --> 00:03:42,800 So, now let's go ahead and hit run and see what happens. 40 41 00:03:43,010 --> 00:03:48,590 And now once we run the app, you'll see that animation occur exactly the same as what we had before, 41 42 00:03:48,830 --> 00:03:54,600 but now we are able to achieve that using just one line of code. 42 43 00:03:54,650 --> 00:04:02,060 So this is a taster into the powers of using third party libraries that you can incorporate into your 43 44 00:04:02,060 --> 00:04:02,660 project. 44 45 00:04:02,750 --> 00:04:09,920 And it's up to you if you want to continue using this pod or if you want to go back to what we had before 45 46 00:04:10,280 --> 00:04:15,180 which is the animation that we generated manually. 46 47 00:04:15,230 --> 00:04:21,890 Now, while you're running this CLTypingLabel, you might notice that you get a warning here talking 47 48 00:04:21,890 --> 00:04:23,850 about something about pies. 48 49 00:04:23,960 --> 00:04:26,630 Sadly, it's not anything that's edible. 49 50 00:04:26,630 --> 00:04:28,060 So what is this all about? 50 51 00:04:28,070 --> 00:04:34,700 Let's go ahead and copy this and paste that warning message into Google to see what we might get. 51 52 00:04:34,820 --> 00:04:41,310 So we're not seeing the exact thing down here so let's try and make this a little bit more specific. 52 53 00:04:41,390 --> 00:04:48,500 We can add some quotes around the word pie and see if we can get some results that are specifically relating 53 54 00:04:48,560 --> 00:04:50,180 this pie thing. 54 55 00:04:50,180 --> 00:04:52,930 And, indeed, we do. We have one right here. 55 56 00:04:53,600 --> 00:05:01,670 So it seems like this pie relates to something called the Position-Independent Executable and it's telling 56 57 00:05:01,670 --> 00:05:08,060 us that the way that we can disable it for our pods, which seems to be the problem we're getting, is to 57 58 00:05:08,090 --> 00:05:16,360 go over to our pods project, build settings, and then search for position, and then change this part to 58 59 00:05:16,380 --> 00:05:16,960 Yes. 59 60 00:05:17,030 --> 00:05:24,130 So let's try that and see if it works. So let's go over to our Pods projects, select it here, and then 60 61 00:05:24,130 --> 00:05:26,400 let's select Pods right here as well, 61 62 00:05:27,400 --> 00:05:37,600 and then we go to Build Settings and we search for "position." And where it says, "Generate 62 63 00:05:37,600 --> 00:05:38,740 Position-Dependent code," 63 64 00:05:38,770 --> 00:05:40,460 we're going to change it 64 65 00:05:40,870 --> 00:05:42,250 to Yes. 65 66 00:05:42,250 --> 00:05:44,230 So, now let's hit run again 66 67 00:05:47,980 --> 00:05:52,090 And you can see that this time, we no longer get that warning. 67 68 00:05:52,090 --> 00:05:57,120 So that's the solution for that warning if you're getting it. And if you're getting a different warning, 68 69 00:05:57,160 --> 00:06:01,110 I also recommend the same system just searching Stack Overflow 69 70 00:06:01,120 --> 00:06:03,240 or Google for the warning message. 70 71 00:06:03,250 --> 00:06:06,530 There's usually somebody else who's encountered it. 71 72 00:06:06,550 --> 00:06:06,840 All right. 72 73 00:06:07,000 --> 00:06:14,170 So at this point, we've seen how to create a pod file, generate an xcworkspace, add a CocoaPod, and successfully 73 74 00:06:14,170 --> 00:06:16,190 use the pod inside our project. 74 75 00:06:16,520 --> 00:06:21,800 There's only one step that I haven't showed you yet and that's removing a pod. 75 76 00:06:21,880 --> 00:06:25,710 In fact, I'm going to remove the CLTypingLabel from my project. 76 77 00:06:25,720 --> 00:06:31,060 That way, you'll learn how to remove a pod if you're no longer interested in using it in your project 77 78 00:06:31,060 --> 00:06:31,950 anymore. 78 79 00:06:32,110 --> 00:06:35,940 Of course, you have the option to leave your code as it is and keep the pod. 79 80 00:06:36,130 --> 00:06:41,440 So you don't have to follow along with me. But I'm going to remove this pod in the completed version 80 81 00:06:41,500 --> 00:06:46,000 of this project and use the code that we wrote ourselves previously. 81 82 00:06:46,000 --> 00:06:51,970 Well, let me restore my titleLabel to a UILabel. And if you want to keep the pod, then you don't have 82 83 00:06:51,970 --> 00:06:52,910 to change your code. 83 84 00:06:52,930 --> 00:06:59,620 You can just watch me as I change my file, and then remove that input statement as well. 84 85 00:06:59,620 --> 00:07:06,820 And the other thing I had to change was to go into our Main.storyboard and change the identity of this 85 86 00:07:07,210 --> 00:07:10,950 back from CLTypingLabel to a UILabel. 86 87 00:07:10,960 --> 00:07:16,140 So once I delete that class, you can see it defaults back to a UILabel. 87 88 00:07:16,210 --> 00:07:20,410 So, now the pod, though, is still right here living in our project, 88 89 00:07:20,410 --> 00:07:26,950 so it means that when we upload our project to the App Store, it's adding maybe a couple of more characters. 89 90 00:07:26,950 --> 00:07:32,170 In this case, it's not particularly bad. It's a really small file. It's really not going to make much of 90 91 00:07:32,170 --> 00:07:32,980 a difference. 91 92 00:07:33,070 --> 00:07:39,340 But if it's a really large module that we've added, you might want to actually remove it from your project. 92 93 00:07:39,340 --> 00:07:40,510 So how do you do that? 93 94 00:07:41,020 --> 00:07:45,500 Well, we go back to the pod file. We remove this particular pod, 94 95 00:07:45,550 --> 00:07:48,280 this line of code, hit save. 95 96 00:07:48,460 --> 00:07:53,370 We close down our project and then we go back into Terminal 96 97 00:07:53,520 --> 00:07:56,040 and we run pod install again. 97 98 00:07:56,170 --> 00:08:01,300 But in this case, we're actually not installing. We're actually uninstalling and you can see that it has 98 99 00:08:01,360 --> 00:08:05,960 removed our CLTypingLabel from our project. 99 100 00:08:06,070 --> 00:08:13,630 Now, if we go back into our FlashChat workspace, you can see that in the pods there are actually no pods 100 101 00:08:13,720 --> 00:08:14,820 in here anymore. 101 102 00:08:14,830 --> 00:08:18,600 We don't have any modules that are being added to our project. 102 103 00:08:19,090 --> 00:08:23,980 But don't delete the pod file because we're going to be using it to add Firebase to our project very 103 104 00:08:23,980 --> 00:08:24,300 soon.