How to Make a Carthage-compatible Framework in Swift

Because I’ll inevitably forget this 3 months from now.

Create a Cocoa Touch Framework

Share the Default Scheme

This lets Carthage know what to build.

First, find the Edit Scheme option,

Then check the Shared option at the bottom of the panel.

Now Add Some Code

public class MySuperCoolClass {
    ... code ...

    public func doTheThing(withTheThing thing : UIThing) -> MYThing {
        ... moar code ...

    func doAnotherThing() {
        ... code ...
        // this func not visibile from project linking this framework

Note that the class (and any methods you want users of the lib to access) must be marked as public.

Develop Locally

Now, to develop locally, drag your Cocoa Touch Framework project into the project or workspace that you want to use it in. If you drag it into a project, Xcode will offer to create a workspace for you. Do that.

Next, add your framework to the “Embedded Binaries” and the “Linked Frameworks and Libraries” sections.

Your classes and whatnot will be available like normal:

import MyModule

class SomeProjectClass : MySuperCoolClass {
  ... code ...


To publish your Carthage-compatible framework, the source must be available on git, but it also needs tags associated with each release.

git tag 0.1.0
git push origin master --tags

Notice the --tags flag to push the tags to the remote; by default they are not included.

Use it!

Fantastic, your code is now on the Internet™.

Test your setup by making a new project and adding your framework to your Cartfile:

github "Shrugs/TabBatScrollableViewController" >= 0.1.0

If you’d like more information about actually using Carthage, the raywenderlch blog post is a good starting point.