Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruthlessly Simple Dependency Management with Ca...

Ruthlessly Simple Dependency Management with Carthage

Carthage is a new dependency manager for Objective-C and Swift projects, intended to be the simplest way to add frameworks to a Cocoa application. Carthage works by delegating tasks to Xcode and Git, minimizing new concepts as much as possible, so you can continue to use the tools you’re already familiar with.

This talk will explain what Carthage is and how to use it, then dive into the philosophy of ruthless simplicity that inspired the project. We’ll also compare and contrast Carthage with CocoaPods, the original dependency manager for Cocoa. Finally, we’ll explore how Carthage is architected under-the-hood, and the benefits we’ve seen from writing it completely in Swift.

Justin Spahr-Summers

April 02, 2015
Tweet

More Decks by Justin Spahr-Summers

Other Decks in Programming

Transcript

  1. Dependencies in Cocoa (historically) 1. Copied source files 2. Zipped

    binaries 3. SVN externals, Git submodules 4. Git subtrees
  2. !

  3. Our goals ⁶ ⁵ 1. Pick compatible versions for all

    dependencies 2. Check out dependencies with Git 3. Build frameworks with Xcode
  4. Step 1: Create a Cartfile github "Mantle/Mantle" ~> 1.5 github

    "ReactiveCocoa/ReactiveCocoa" >= 2.4.7 github "ReactiveCocoa/ReactiveCocoaLayout" == 0.5.2
  5. Step 2: Run Carthage $ carthage update *** Fetching Mantle

    *** Fetching ReactiveCocoa *** Fetching ReactiveCocoaLayout *** Fetching Archimedes *** Downloading Archimedes at "1.1.4" *** Downloading Mantle at "1.5.4" *** Downloading ReactiveCocoa at "v2.4.7" *** Downloading ReactiveCocoaLayout at "0.5.2"
  6. ! Parsing Parse OGDL into a list of dependencies github

    "ReactiveCocoa/ReactiveCocoa" >= 2.4.7
  7. ! Parsing Parse OGDL into a list of dependencies github

    "ReactiveCocoa/ReactiveCocoa" >= 2.4.7 Determine the type of each dependency github "ReactiveCocoa/ReactiveCocoa"
  8. ! Parsing Parse OGDL into a list of dependencies github

    "ReactiveCocoa/ReactiveCocoa" >= 2.4.7 Determine the type of each dependency github "ReactiveCocoa/ReactiveCocoa" Parse any Semantic Version >= 2.4.7
  9. 㿃 Resolving Create a graph of the latest dependency versions

    Demo ReactiveCocoa 3.0 ReactiveCocoaLayout 0.5.2 Mantle 1.5.4
  10. 㿃 Resolving Insert dependency Cartfiles into the graph Demo ReactiveCocoa

    3.0 ReactiveCocoaLayout 0.5.2 Mantle 1.5.4 2.4.7 Archimedes 1.1.4
  11. 㿃 Resolving If requirements conflict, throw out the graph Demo

    ReactiveCocoa 3.0 ReactiveCocoaLayout 0.5.2 Mantle 1.5.4 2.4.7 Archimedes 1.1.4
  12. 㿃 Resolving Try a new graph with the next possible

    version Demo ReactiveCocoa 2.4.7 ReactiveCocoaLayout 0.5.2 Mantle 1.5.4
  13. 㿃 Resolving Repeat until a valid graph is found Demo

    ReactiveCocoa 2.4.7 ReactiveCocoaLayout 0.5.2 Mantle 1.5.4 2.4.7 Archimedes 1.1.4
  14. ! Downloading 1. Fetch the repository into Carthage’s cache 2.

    Copy the right version into Carthage/Checkouts
  15. ! Building 1. Symlink Carthage/Build into the dependency folder 2.

    List framework schemes from the .xcodeproj
  16. ! Building 1. Symlink Carthage/Build into the dependency folder 2.

    List framework schemes from the .xcodeproj 3. Build each scheme for all supported architectures
  17. ! Building 1. Symlink Carthage/Build into the dependency folder 2.

    List framework schemes from the .xcodeproj 3. Build each scheme for all supported architectures 4. Combine multiple architectures with lipo
  18. ! Building 1. Symlink Carthage/Build into the dependency folder 2.

    List framework schemes from the .xcodeproj 3. Build each scheme for all supported architectures 4. Combine multiple architectures with lipo 5. Copy the built frameworks into Carthage/Build
  19. Dynamic frameworks vs. static libraries 4 iOS 8+ only 4

    Can include resources 4 Self-contained and ready-to-use 4 Avoid duplicate symbol errors 4 Required for Swift
  20. Swift vs. Objective-C 4 Type safety 4 Value types (especially

    enums) 4 Much faster to write 4 Better modularization 4 The Next Big Thing™
  21. ReactiveCocoa 4 Simplifies networking (with the GitHub API) 4 Simplifies

    the dependency resolver 4 Simplifies shelling out, via ReactiveTask 4 Carthage helps test RAC 3.0 in the real world
  22. 1.0

  23. Questions? Comments? Slides and notes, plus my demo project, are

    available at: https://github.com/jspahrsummers/carthage-talk Thanks to everyone who reviewed this presentation, and to Realm for inviting me to speak!2 2 ❤ Matt Diephouse, Rob Rix, Alan Rogers, Keith Duncan, Nacho Soto, Tom Brow, James Lawton, Arwa Jumkawala, JP Simard, Tim Anglade, Brendan Forster, Benjamin Encz, Robert Böhnke, and you!