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