Skip to content

Instantly share code, notes, and snippets.

@pxlshpr
Last active October 19, 2017 21:05
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save pxlshpr/21f4e298a08a791fa4aa to your computer and use it in GitHub Desktop.
Save pxlshpr/21f4e298a08a791fa4aa 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.
  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.
@damianesteban
Copy link

This is quite convenient. Thanks.

@phamquochoan
Copy link

$(PROJECT_DIR)Carthage/Build/iOS should be $(PROJECT_DIR)/Carthage/Build/iOS, right ?
(extra / between project_dir and carthage)

@pxlshpr
Copy link
Author

pxlshpr commented Jan 21, 2017

@phamquochoan it sure should have been. Thanks!

@Nadohs
Copy link

Nadohs commented Oct 19, 2017

the images are gone ; (

@Nadohs
Copy link

Nadohs commented Oct 19, 2017

copy-frameworks

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