0 1 00:00:00,810 --> 00:00:08,010 This lesson is all about understanding and fixing potential problems with pod installation. At some point, 1 2 00:00:08,100 --> 00:00:11,340 you'll be installing your own pods for your own projects. 2 3 00:00:11,340 --> 00:00:16,950 So it's really important to understand how this process works, so you'll be able to fix them if they 3 4 00:00:16,950 --> 00:00:18,470 arise in the future. 4 5 00:00:18,780 --> 00:00:25,590 In the process, you're going to get an understanding of how pods are updated and how to specify a particular 5 6 00:00:25,590 --> 00:00:29,860 version of the pod using the pod file. 6 7 00:00:29,970 --> 00:00:36,120 The first thing you should do after installing your pods and opening your xcworkspace is to build your 7 8 00:00:36,120 --> 00:00:37,080 project. 8 9 00:00:37,140 --> 00:00:45,330 So hold on command on your keyboard and hit B in order to build. And in certain cases, you might get errors 9 10 00:00:45,330 --> 00:00:51,920 that are because of certain lines of code in the newly added pod files. Because we know before we added 10 11 00:00:51,920 --> 00:00:53,890 the pod files, we had no problems. 11 12 00:00:54,090 --> 00:00:56,100 But now we've got 4 errors. 12 13 00:00:56,100 --> 00:00:59,090 So let's click on it and see what it's telling us to do. 13 14 00:00:59,790 --> 00:01:06,540 It's telling us that there's a number of things that have updated in Swift. So there's some changes that 14 15 00:01:06,540 --> 00:01:08,250 it's suggesting us to make. 15 16 00:01:08,250 --> 00:01:13,560 For example, here, it's telling us that the character's property is no longer used. 16 17 00:01:14,040 --> 00:01:22,650 Instead, we should be using that string directly. So it wants us to change some code that comes from this 17 18 00:01:22,650 --> 00:01:25,010 pod CLTypingLabel. 18 19 00:01:25,170 --> 00:01:27,600 Now, what's going on here? 19 20 00:01:27,600 --> 00:01:34,620 Well, if we head back over to our CLTypingLabel page on CocoaPods, and then navigate to the GitHub 20 21 00:01:34,620 --> 00:01:43,650 page through this link, if you take a look at the Pull requests and look at the Closed ones, you can see 21 22 00:01:43,650 --> 00:01:51,840 that people have been updating this repository to fix some of these problems, right, the characters method 22 23 00:01:52,020 --> 00:01:53,910 which we saw just now. 23 24 00:01:53,940 --> 00:02:01,020 So in this case, it's getting the error: "The method characters is deprecated," so instead, they're updating 24 25 00:02:01,020 --> 00:02:03,690 the code to use the string method instead. 25 26 00:02:03,930 --> 00:02:06,520 And you can take a look at the files that they've changed. 26 27 00:02:06,630 --> 00:02:14,310 So for example, instead of characters.count > 0, they've changed it to this line here. 27 28 00:02:14,520 --> 00:02:19,530 So let's go ahead and copy this line which was added and remove this line 139 28 29 00:02:19,530 --> 00:02:27,180 that was deleted, and then click Unlock to unlock the file, and then replace it with this new line 29 30 00:02:27,480 --> 00:02:29,690 that we got from the GitHub. 30 31 00:02:30,220 --> 00:02:37,520 So, now if I hit command B, you can see that I no longer have any errors associated with this line. 31 32 00:02:37,710 --> 00:02:43,670 So clearly, we're getting some fixes that have been added to the repository. 32 33 00:02:43,710 --> 00:02:51,390 Now, when you head back over to the code tab and you click on releases, you can see that the latest version 33 34 00:02:51,450 --> 00:02:57,150 of this pod or this repository that was released is 0.4.0. 34 35 00:02:57,300 --> 00:03:01,540 And this is the release that supports Swift 4 and 5. 35 36 00:03:01,620 --> 00:03:08,640 So notice how a lot of these errors are because the code is using a lower version of Swift. 36 37 00:03:08,640 --> 00:03:16,490 In fact, a lot of these errors have actually been addressed already by the makers of this particular pod. 37 38 00:03:16,650 --> 00:03:23,730 But if we take a look inside our Flash-Chat-iOS13 folder, you can see that there's a file called 38 39 00:03:23,730 --> 00:03:25,710 PodFile.lock. 39 40 00:03:25,710 --> 00:03:31,050 So if you go ahead and right click on it, then select Open With, and we're going to, again, select Xcode 40 41 00:03:31,110 --> 00:03:39,310 to open it, and then click Open. You can see that it tells us which pods we have added to our project. 41 42 00:03:39,480 --> 00:03:45,270 And the only one is this one called CLTtypingLabel. And the version, though, 42 43 00:03:45,270 --> 00:03:46,070 is 0.3.0. 43 44 00:03:46,140 --> 00:03:51,490 So it's lower than the latest release. In fact, our one 44 45 00:03:51,510 --> 00:03:55,460 is this one that was released in October, 2017. 45 46 00:03:55,860 --> 00:04:03,330 So why is it that we're not able to get this latest version? Now, if we go back to the CocoaPod guides 46 47 00:04:03,720 --> 00:04:10,170 and we look at the pod file Reference, you can see that we can actually specify a specific version of 47 48 00:04:10,170 --> 00:04:12,140 the pod that we want to use. 48 49 00:04:12,150 --> 00:04:16,710 So in this case, they're using AFNetworking 1.0 version. 49 50 00:04:16,830 --> 00:04:23,370 So if we go back to our pod file, so not the Podfile.lock, but the actual pod file which you'll 50 51 00:04:23,370 --> 00:04:27,970 be able to find inside your Xcode project as well right here, 51 52 00:04:27,990 --> 00:04:34,020 notice how it's on RB or Ruby file and it has all of the changes that we made before. 52 53 00:04:34,020 --> 00:04:40,590 Well, instead of just telling it to use any old pod file, we're going to add the same syntax as we see 53 54 00:04:40,590 --> 00:04:40,860 here. 54 55 00:04:40,890 --> 00:04:45,870 So a comma followed by a single quote, and inside a single quote, 55 56 00:04:45,870 --> 00:04:51,720 we've got a tilde symbol, and then a right angle bracket, and then the version of that pod that we 56 57 00:04:51,720 --> 00:04:52,730 want to use. 57 58 00:04:52,740 --> 00:05:00,510 So back over here, I'm going to add, first, a comma, then a single quote, and then a tilde symbol, a right 58 59 00:05:00,540 --> 00:05:09,030 angle bracket, space, and then 0.4.0, and then closing it off with a single quote. 59 60 00:05:09,060 --> 00:05:14,670 So just check to see that what you've typed is exactly the same as what you see on the screen right 60 61 00:05:14,700 --> 00:05:15,590 now. 61 62 00:05:15,750 --> 00:05:18,040 And then we're going to hit save. 62 63 00:05:18,400 --> 00:05:25,630 So, now let's close down our project, go back to Terminal, and we're going to run a pod install again. 63 64 00:05:25,630 --> 00:05:30,490 And instead typing it out, I'm just going to hit the up arrow which you'll see cycles through all of the 64 65 00:05:30,490 --> 00:05:37,000 previous commands I've issued. And the one immediately before was pod install which I wrote here. 65 66 00:05:37,480 --> 00:05:44,290 So, now I've got that selected, I'm gonna hit enter to execute it. And notice how we're getting an error 66 67 00:05:44,290 --> 00:05:44,940 here. 67 68 00:05:45,010 --> 00:05:50,160 It says, "CocoaPods could not find compatible versions with 'CLTypingLabel.'" 68 69 00:05:50,200 --> 00:05:58,000 This particular version, the specification satisfying naught .4.0 were found, but they 69 70 00:05:58,000 --> 00:06:00,910 required a higher minimum deployment target. 70 71 00:06:01,030 --> 00:06:04,060 So what is all of this mean in English anyways? 71 72 00:06:04,060 --> 00:06:12,700 Well, it means that, yes, they found this 0.4.0 version of CLTypingLabel, but that 72 73 00:06:12,700 --> 00:06:17,730 version requires you to have a higher minimum deployment target. 73 74 00:06:17,770 --> 00:06:24,400 So let's go ahead and open up our pod file again. And remember how back when we started out creating 74 75 00:06:24,400 --> 00:06:32,410 our pod file, we specified a minimum deployment target of 9.0. 75 76 00:06:32,410 --> 00:06:38,740 Well, this 0.4.0 version actually requires a higher minimum than 9.0. 76 77 00:06:38,740 --> 00:06:40,050 How would we know this? 77 78 00:06:40,060 --> 00:06:50,380 Well, if I go back to our GitHub page for CLTypingLabel and we go into the pod spec file, you'll see 78 79 00:06:50,410 --> 00:06:58,290 that the specification requires platform minimum iOS version 10.0 or above. 79 80 00:06:58,300 --> 00:07:04,060 So that's why we're not able to get the latest version of this pod is because we're saying that our 80 81 00:07:04,060 --> 00:07:07,420 project has to support everything from 9 and above, 81 82 00:07:07,540 --> 00:07:11,680 but this pod is only available for projects which are 10 or above. 82 83 00:07:11,740 --> 00:07:13,590 So let's go ahead and fix this. 83 84 00:07:13,600 --> 00:07:21,670 Let's change this to, in fact, to go all the way to 13 because we're only going to support iPhones running 84 85 00:07:21,700 --> 00:07:24,520 iOS 13 or above. 85 86 00:07:24,520 --> 00:07:30,480 Now, we're going to hit save on our pod file and we're going to leave this line as it is, and then we're 86 87 00:07:30,480 --> 00:07:35,500 going to go back to our Terminal and we're going to run pod install again. 87 88 00:07:35,820 --> 00:07:39,090 And notice how this time we installed 0.4.0, 88 89 00:07:39,150 --> 00:07:41,830 whereas it used to be 0.3.0. 89 90 00:07:41,870 --> 00:07:50,130 We've made all of those updates. And now if we open up are white xcworkspace project for our FlashChat again, 90 91 00:07:50,130 --> 00:07:57,690 you'll notice that when we hit command B to build that we don't have any of those errors 91 92 00:07:57,720 --> 00:07:59,530 that we saw earlier on. 92 93 00:07:59,700 --> 00:08:07,380 And in fact, it's completely compatible with the latest version of iOS and Swift, and we're no longer 93 94 00:08:07,410 --> 00:08:12,600 getting any errors that are coming from that latest pod. 94 95 00:08:12,740 --> 00:08:20,540 Now, I've chosen this pod, in particular, to show you firstly because it is able to replace all of the 95 96 00:08:20,540 --> 00:08:24,370 code that we have to write here in order to animate our label. 96 97 00:08:24,590 --> 00:08:32,030 But it also allowed me to show you the issues with the pod spec, as well as the minimum versioning in 97 98 00:08:32,030 --> 00:08:38,810 our pod file, because these are things that you might encounter in future when you're using different 98 99 00:08:38,810 --> 00:08:45,980 third party libraries that you might need. But normally, incorporating a CocoaPod is not that difficult. 99 100 00:08:45,980 --> 00:08:52,880 All you have to do is create the profile, add the pods that you want to incorporate, run pod install, and 100 101 00:08:52,880 --> 00:08:57,040 you should be ready to go without all of these errors that you have to fix. 101 102 00:08:57,140 --> 00:09:04,410 But now that we've finally added our CLTypingLabel, let's check out how we're supposed to use it. 102 103 00:09:04,580 --> 00:09:07,160 And that's exactly what we'll do in the next lesson. 103 104 00:09:07,280 --> 00:09:09,890 So for all of that and more, I'll see you there.