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

Carthage Tips & Tricks

Carthage Tips & Tricks

A quick overview of carthage and some usage tips & tricks

Tommaso Piazza

May 10, 2018
Tweet

More Decks by Tommaso Piazza

Other Decks in Technology

Transcript

  1. Carthage Tips & Tricks Tommaso Piazza @tmpz https://github.com/blender Tommaso Piazza

    @tmpz - UIKonf Unconference 16/05/2018 1
  2. What is Carthage Dependency management tool • Written in Swift

    • ReactiveSwift (not RxSwift) https://github.com/Carthage/Carthage Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 2
  3. What can Carthage do for me • Fetch depedencies •

    Resolve dependecies • Build dependecies • Copy dependencies in appropriate places • Won't touch your project files From here on, you're on your own. Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 3
  4. Installing Carthage brew install carthage • source (super easy) •

    .pkg • .zip Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 4
  5. File Based • Cartfile (Commit this) • Cartfile.resolved (Up to

    you to commit) • Cartfile.private (Commit this) Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 5
  6. Cartfile Declare your dependecies here github "Alamofire/Alamofire" ~> 4.2.0 git

    "ssh://stash.puppylist.com/puppy-project/puppy-core.git" "feature/puppy-list" binary "Fabric.json" == 5.0.0 binary "file:///Users/blender/Code/Personal/DoKit/DoKit.json" ~> 0.3.0 binary "https://dl.google.com/dl/firebase/ios/carthage/firebasedatabasebinary.json" Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 6
  7. Cartfile.resolved This file contains the actual resolved versions github "Alamofire/Alamofire"

    "4.7.2" git "ssh://stash.puppylist.com/puppy-project/puppy-core.git" "ab1627571bf7182857e47178d4812" binary "Fabric.json" 5.0.0 binary "file:///Users/blender/Code/Personal/DoKit/DoKit.json" 0.3.0 binary "https://dl.google.com/dl/firebase/ios/carthage/firebasedatabasebinary.json" "5.0.1" Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 7
  8. Cartfile.private Put dependecies you don't want to pass on here

    github "swisspol/GCDWebServer" ~> 3.2 Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 8
  9. Using Dependencies • Drag and drop them in your project

    • Add Run Script Phase carthage copy-frameworks Add Inputs & Outputs to the copy-frameworks script Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 9
  10. Pin your depedendencies If you don't, Carthage will match anything

    • At the mercy of the maintainers of your dependencies • Undecidable tags • Conflicting versions Don't do this binary "https://raw.githubusercontent.com/Building42/Specs/master/Carthage/Fabric.json" github "BranchMetrics/ios-branch-deep-linking" github "intercom/intercom-ios" github "CocoaLumberjack/CocoaLumberjack" github "evsinev/BerTlv" Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 10
  11. New resolver Carthage hangs indefinitely? ! Uses too much memory?

    " • --new-resolver • Check your Cartfile ! • Best to pin versions (avoid surprises) ~> x.y.z Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 11
  12. Less rebuilds Save time! ⏱ Avoid rebuilding dependencies • --cache-builds

    • use a cache for cold starts (Rome) Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 12
  13. DSYMs & Debug Symbols • Carthage will produce .dSYMs •

    Binaries include debug symbols by default Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 13
  14. Smaller binaries Reduce the size of your app by enabling

    • COPY_PHASE_STRIP=YES (defaults to no) • carthage copy-frameworks will do the rest Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 14
  15. Outdated depedencies Carthage has you covered! To Build Phases ➕

    a new Run Script Phase • carthage outdated --xcode-warning Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 15
  16. Update just one dependecies carthage update X Tommaso Piazza @tmpz

    - UIKonf Unconference 16/05/2018 16
  17. New version faster A fix to your problem just got

    merged? • brew upgrade carthage --HEAD Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 17
  18. Still having issues? Maintainers would ❤ if you • Searched

    the existing issues before • Filled in as much details as you can • Provided a sample project (zip) Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 18
  19. Thanks! Thanks to all contributors that made this possible! •

    Pull request always welcome! • Very easy to get started! • hack, pr, comments, repeat, merged! ✅ Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 19