Swift.iOS: CocoaPods – Editing a Podfile

In this lesson

Editing a Podfile is pretty easy once you’ve got the syntax down but there is plenty to watch out for when defining your pods!

Kyle Roberts
Swift Guru at Large

Kyle's Series

Transcript

Tap on time to skip ahead

00:10

Hello world. Kyle here with Brax.tv. Let’s talk about editing a Podfile. We’re on CocoaPods.org, we have copied many many times, you can probably hear me clicking insanely furiously on this Alamofire item here to copy the current pod item line for Alamofire version 3.4.

00:39

Here we are in the Pods project with the Podfile open. This is our existing thing. Let’s actually delete Alamofire, just for this example, since we’ve already copied the Alamofire pod list item from CocoaPods.org. All we have to do is copy that in there and it’s great, except tabs being ridiculous. And we have added a pod to our Podfile.

01:03

Let’s also talk about some of the other stuff going on here in this Podfile. This use_frameworks line is required when using CocoaPods with Swift development. I believe if you’re only writing in Objective-C this use_frameworks line is optional. And by optional I mean you can just completely remove it. This header here is optional. We’re just defining that we’re on the iOS platform using version 9.0 minimum of iOS. In this specific Podfile, we are defining our target, SteamReader, or we are selecting our target, SteamReader, installing all of these pods to it, then ending that block there.

01:46

Since we’re only working with this one target at the moment, we can actually delete it and it will perform the same thing. Whatever, this is future proofing it in case we want to expand on different targets later. I have two test targets with this project.

02:00

That’s the basics of editing a Podfile. Again, this header is not even required. In every example anywhere of CocoaPods they have this, even on the website or when you run pod init and then have it create this template Podfile for you. Not this one but when it creates a template for you.

02:20

But the most important rule ever when editing a Podfile is to not use TextEdit. TextEdit, that is of course, the OS X application TextEdit that’s just the default plain text editor in OS X. TextEdit, when editing a Podfile, uses smart quotes instead of the single quotes here that we see in this Podfile. CocoaPods has trouble reading that and even complains about it in the log output when running pod install. I would recommend using either Xcode like this or TextWrangler or any other editor that either does not use smart quotes or has the option to turn them off.

Additional Info

Register to get access to additional resources and info.