Skip to main content

Ha you have read it before, one of those throw away lines that is written "just create a cartfile".  So your thinking carthage update, carthage init, create a plain text document, etc... all wrong.  How do you know... when you run carthage update, you receive the following error

Get this error: "No such file in directory"

So how do you "just" create a Cartfile?

Oh, there are no instructions on the Carthage page either.  Feeling a little ticked off, how do I "just create" a Cartfile?

Using Terminal, using cd go to the root directory of the project where your *.xcodeproj file is located

cd ~/Path/To/Your/Project/

Create an empty file called Cartfile like this:

touch Cartfile

Open that file with Xcode:

open -a Xcode Cartfile

Paste the framework info that you need into the Cartfile. For example:

github "acquia/waterwheel-swift" ~> 4.3.4

Close the file in Xcode and in Terminal run the following command to make Carthage update the dependencies in your project. (You should still be in the same directory as your Cartfile.)

carthage update --platform iOS

For me the above line failed and I had to use

carthage update --use-submodules --platform iOS

To find out more about using --use-submodules, see Kyle Browning's comment on Github.

Framework set-up in your project

In the {your}.xcodeproj set it up for the frameworks that you have added through the carthage update process.  First, copy debug symbols for debugging and crash reporting on OS X.  Open {your}.xcodeproj and perform the following steps:

  1. Under Build Phases settings tab for the project target, click the + icon and choose New Copy Files Phase.

  2. Click the Destination drop-down menu and select Products Directory.

  3. Drag and drop each framework that is being used to the corresponding dSYM file.  As a reference I added the following Alamofire.framework.dSYM, AlamofireImage.framework.dSYM, ObjectMapper.framework.dSYM, SwiftyJSON.framework.dSYM, SwiftyUserDefaults.framework.dSYM, waterwheel.framework.dSYM

As you are building for iOS (this also applies for tvOS or watchOS)
  1. In the {your}.xcodeproj targets’ General settings tab, in the Linked Frameworks and Libraries section, add each framework that you are using from the Carthage/Build/iOS folder.  I added Alamofire.framework, AlamofireImage.framework, ObjectMapper.framework, SwiftyJSON.framework, SwiftyUserDefaults.framework, waterwheel.framework

  2. In the {your}.xcodeproj targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), below the shell script area add:

    1. /usr/local/bin/carthage copy-frameworks
  3. Add the framework paths under Input Files.  I added the following:

    1. $(SRCROOT)/Carthage/Build/iOS/Alamofire.framework
  4. Add the framework paths under Output Files.  I added the following:

    1. $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework

The above couple of examples are referenced from the Carthage github page.  I have added clear examples of what is required when adding Waterwheel framework to your project.