Skip to content

Instantly share code, notes, and snippets.

@embassem
Forked from pxlshpr/Carthage Instructions.md
Last active February 15, 2016 10:18
Show Gist options
  • Save embassem/29b37d4672f8b2652083 to your computer and use it in GitHub Desktop.
Save embassem/29b37d4672f8b2652083 to your computer and use it in GitHub Desktop.
These are the steps required to add and embed a framework into your project using Carthage.

cd ~/Path/To/Starter/Project touch Cartfile open -a Xcode Cartfile carthage update --platform iOS

  1. Add the URL of the framework's repo to your Cartfile using one of the following:
  github "ReactiveCocoa/ReactiveCocoa" # GitHub.com
  github "https://enterprise.local/ghe/desktop/git-error-translations" # GitHub Enterprise
  git "https://enterprise.local/desktop/git-error-translations2.git"
  git "/Users/user/foo/bar.git"

…optionally followed by one of the following version specifiers:

  >= 1.0 for “at least version 1.0
  ~> 1.0 for “compatible with version 1.0
  == 1.0 for “exactly version 1.0
  "some-branch-or-tag-or-commit" for a specific Git object (anything allowed by git rev-parse)  
  1. Run carthage update. This will clone and build the framework for you.

  2. Drag-and-drop the framework into your Xcode project. It should be located here:

  ../Carthage/Build/iOS/Framework.framework
  1. Add the framework in Embedded Binaries, under the target's General settings tab. Screenshot

  2. Add the Carthage build directory to your Framework Search Paths under the target's Build Settings.

  $(PROJECT_DIR)Carthage/Build/iOS

Screenshot

  1. Add a run script under the project's Build Phases that runs Carthage's copy-frameworks tool.
  /usr/local/bin/carthage copy-frameworks

Screenshot

  1. Make sure you add the path to the built framework as an input file to the run script.
  $(SRCROOT)/Carthage/Build/iOS/Framework.framework

Screenshot

  1. Now, simply use import Framework anywhere in your project to use its public interface. 9.If you're building for iOS, tvOS, or watchOS

Create a Cartfile that lists the frameworks you’d like to use in your project. Run carthage update. This will fetch dependencies into a Carthage/Checkouts folder, then build each one. On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:

/usr/local/bin/carthage copy-frameworks and add the paths to the frameworks you want to use under “Input Files”, e.g.:

$(SRCROOT)/Carthage/Build/iOS/Box.framework $(SRCROOT)/Carthage/Build/iOS/Result.framework $(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files and dSYMs are copied when archiving.

With the debug information copied into the built products directory, Xcode will be able to symbolicate the stack trace whenever you stop at a breakpoint. This will also enable you to step through third-party code in the debugger.

When archiving your application for submission to the App Store or TestFlight, Xcode will also copy these files into the dSYMs subdirectory of your application’s .xcarchive bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment