Install C4

Pick your weapon of choice and start kung-fu'ing some code.

There are a few ways to install C4:

Jackie Chan

The easiest way to create new projects is to install C4 directly into Xcode. I highly recommend this approach because it makes it extremely easy to quickly create new projects and test out your ideas.

C4 Installer

The latest stable C4 release.

  1. Download the installer
  2. Double-click the .pkg to open it up
  3. Follow the instructions to install
  4. Open Xcode

At this point, you’ll see a dialog that looks like this:

Select: Create New Xcode Project
Select: Create New Xcode Project
  1. Select “Create New Xcode Project
  2. Give your project a name
  3. Choose the device to build for
  4. Save the project somewhere
  5. When your project opens, choose the WorkSpace.swift file
  6. Hit Run

That’s it! You’ve created a new C4 project.


Like I mentioned above, I personally think this is the easiest way to test C4 projects. You can quickly create new projects, all the test media are included, and its an easy setup for copying and pasting any example code from our site straight into the WorkSpace. Furthermore, the code that installs is static so it should always work out of the box.


The only significant drawback is that this installs a static copy of C4’s code base in every project you create. If there are updates to the core C4 project on Github this installer won’t update automagically. You’ll have to wait until we create a new installer build.


The next level of mastery is to use Cocoa Pods. You’ll have to do a few things to get this running:

  1. Install cocoa pods

    1. Create a new Xcode project (iOS: Single-View application)
    2. Close the Xcode project
    3. Open Terminal and navigate to the top level folder of your project. For example, you could write:
      cd /Users/Mac/Desktop/C4CocoaPod
    4. Then, create a pod file by entering: touch Podfile .
    5. Then, open the folder with the pod file: open .
    6. Then add the following to the pod file:

target 'TitleOfYourProject' do
  pod 'C4', '~> 3.0.1'

This is a little instruction that tells cocoa pods where to install things.

Remember to change the TitleOfYourProject. I used C4CocoaPod as the title of mine.

  1. Back in Terminal, in the same directory, type: pod install

This is what my terminal output looks like at this point:

Computer:~ SlantMacPro$ cd /Users/Computer/Desktop/C4CocoaPod 
Computer:C4CocoaPod SlantMacPro$ touch Podfile .
Computer:C4CocoaPod SlantMacPro$ open .
Computer:C4CocoaPod SlantMacPro$ pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing C4 (1.0.2)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `C4CocoaPod.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
S0106003ee1c0f960:C4CocoaPod SlantMacPro$ 

Now, we need to update the Xcode project so that it works with the pod’ed thing.

  1. Open the .xcworkspace project
  2. Open ViewController and change its contents to look like this:
import UIKit
import C4

class ViewController: CanvasController {
    override func setup() {
        canvas.backgroundColor = C4Blue
  • 3. Run it.



Installing this way takes a bit more effort, but it guarantees that you always have the latest version of C4 that has been updated into the CocoaPod. Say, for instance, you make a project and then come back to it a couple weeks later (after we’ve updated) you can run pod update and it will bring everything up to speed.


You have to work with .xcworkspaces, which isn’t much of a problem. You might have some issues compiling the first time, but after getting things running a couple of times you’ll learn how to get past this. But, the main thing for me is that you’ll have to convert a normal Xcode project to use C4 every time… Which is slower than just creating a new project from a template.

The Guy From Ong Bak

Carthage… The brutal, light, efficient weapon of choice for many developers. Carthage installs the bare minimum you need and, unlike Cocoapods, doesn’t create a workspace that has everything set up for you.

This is how Alejandro teaches us to install via Carthage:

  1. Install Carthage
  2. Create Cartfile and in it paste github "C4Labs/C4iOS" ~> 1.1.0
  3. Run carthage update
  4. In your project reference the framework in Carthage/Build/iOS/C4.framework

Installing C4 this way is like the trophy at the top of the tree in Ong Bak… Good luck.


Super light installer of the necessary C4 framework components.


More painful terminal experience. You have to do all the linking to the installed C4 framework yourself, from Xcode.

Jet Li

Github for Mac. We host C4 on Github, so downloading their desktop application is one of the easiest ways of managing your projects. Through this tool you’ll be able to clone the C4 project onto your comp.

  1. Download Github for Mac
  2. Click the Clone in Desktop link
  3. Open Xcode
  4. Create new Single-View application
  5. Right-click on ViewController.swift
  6. Choose “Add files to “New”…”
  7. Navigate to your recently downloaded C4iOS.xcodeproj and choose it.
  8. Embed the linked framework into your Xcode. In General > Embedded Binaries click the + and add C4.framework
  9. Update the ViewController so it is a CanvasController… There will probably be a warning.
  10. Build the framework (for the simulator)
  11. In setup() change the background color to blue.
  12. Run the app (for the simulator)


This way you’ll have a single copy of C4 on your computer, and through the Github app, you’ll be able to update that project at any time to keep it current. You’ll also be able to test any of the branches for the project. You’ll also be able to import the same project into ANY of the new Xcode projects you create. So, this approach gives you a nice way of keeping everything current, around a central project.


Takes much longer to set up a project. There are some git tricks that you cannot do with the Github app… It’s pretty decent, but there are some advanced techniques that I always have to fall back on Terminal to accomplish.

Bruce Lee

The martial arts master of keeping things up to date. Use Git, do everything from Terminal, fork, push, pull, rebase, etc. This one you’ll have to figure out on your own (for now).



Ultimate control.


Ultimate control.