Carthage build: Building dynamic frameworks

In this lesson

In this lesson, I will teach you how to use carthage build to build dynamic frameworks from the application dependencies you have declared in your Cartfile and Cartfile.private files

Transcript

Tap on time to skip ahead

00:10

In this lesson, we’re going to learn how to build the dependencies that we resolved previously using the carthage update command. Just to refresh, I have all my dependencies. I’m going to run carthage help to show you want command we’re going to run next. I’m going to use the build command. I’ve already got my dependencies. If we look here, if we remember, they are in the Carthage folder in the Checkouts. Those are all my dependencies that have been resolved already by running carthage update.

00:54

Let me clear. I’m going to run carthage build and I’m going to pass a command line parameter to the build command called –platform because I only want iOS platforms. Otherwise, it’s going to build frameworks for every platform, that includes Mac, tvOS, iOS and watchOS. That’s going to take a long time. It’s going to take a long time anyway. Let’s leave it at iOS. If I want to build for multiple I can certainly specify a comma separated list as an argument to the –platform, a command line argument. But I’m just going to use iOS. I’m going to let this run and we’ll come back when this is finished.

01:44

Welcome back. Well that took about 10 minutes and that was just for building the ios platforms of all these dependent frameworks. I’m going to scroll back here, I hope this doesn’t make you dizzy, and look at where I started this. You’ll notice that the output from the carthage build –platform ios was that it started building iOS targets for each of the dependencies and it continued all the way through until it completed. Let’s see what happened, what the result is of the carthage build process.

02:21

To do that, I’m going to use Finder. I’ve navigated to MyNewApp and we’ve previously looked at the Checkout subfolder of the Carthage folder that was generated when we ran Carthage update. By running carthage build, you’ll notice that there is a new subfolder of the Carthage folder. If we expand that, it includes a subfolder for each platform that we build. Since we built only ios, there’s only one folder. If I expand that, you’ll notice there’s quite a bit of things in here. Specifically, the things we’re interested in are the frameworks and the debug symbols. It generated for each of my dependencies a framework and the debug symbols. Now, we’re ready to include all of this in our application.

03:17

The last thing I want to talk about is the fact that we can actually combine both of those previous steps into one. I’m going to type carthage help again. Remember that we used carthage update to retrieve the dependencies. I’m going to show you, actually, I can say carthage help update, and it will give me all kinds of help on just the update command. We previously specified –no-build during our initial step just to show the process of retrieving the dependencies.

03:53

I’m going to show you that you can actually do both of those steps together. We can combine a retrieval and a build by using carthage update –use-ssh, which is a flag I prefer to use. I can also specify the –platform here. By doing this it will both retrieve and build the dependencies in my Cartfile. This will take quite a while, as you can expect. But this is a way that you would normally use it, combining both steps into one.

Additional Info

Register to get access to additional resources and info.