Slide 1

Slide 1 text

Carthage Tips & Tricks Tommaso Piazza @tmpz https://github.com/blender Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 1

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Installing Carthage brew install carthage • source (super easy) • .pkg • .zip Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 4

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

DSYMs & Debug Symbols • Carthage will produce .dSYMs • Binaries include debug symbols by default Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 13

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Update just one dependecies carthage update X Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 16

Slide 17

Slide 17 text

New version faster A fix to your problem just got merged? • brew upgrade carthage --HEAD Tommaso Piazza @tmpz - UIKonf Unconference 16/05/2018 17

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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