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