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

Carthage

 Carthage

Talk from NSLondon about the Carthage Dependency Management system for Xcode

Abizer Nasir

July 30, 2015
Tweet

More Decks by Abizer Nasir

Other Decks in Programming

Transcript

  1. Carthage
    Abizer Nasir | @abizern | abizern.org

    View Slide

  2. Yet Another Dependency
    Manager

    View Slide

  3. Developed after Swift and
    framework support in iOS

    View Slide

  4. Getting Carthage
    4 https://github.com/Carthage/Carthage/releases
    (pre-built)
    or
    4 brew update && brew install carthage
    4 You may need to tweak xcode-select

    View Slide

  5. What Does it do?
    4 Takes a list of dependencies, that may have their own
    dependencies
    4 Resolves versions
    4 Fetches the dependencies
    4 builds them with their own project settings

    View Slide

  6. That’s it!
    The rest is up to you!

    View Slide

  7. Your Job
    4 Link the frameworks to the correct target
    4 Add a workaround script

    View Slide

  8. Cartfile
    github “ReactiveCocoa/ReactiveCocoa” >= 2.3.1
    github “Mantle/Mantle” ~> 1.0
    github “jspahrsummers/libextobjc” == 0.4.1
    #arbitrary server
    git “https://enterprise.local/desktop/git-error-translations.git” “development”
    #local file
    git “file:///directory/to/project” “branch”

    View Slide

  9. Normal Semantic versioning
    4 >= 1.0 for “at least version 1.0”
    4 ~> 1.0 for “compatible with version 1.0”
    4 == 1.0 for “exactly version 1.0”
    4 “some-branch-or-tag-or-commit” for a specific Git
    object (anything allowed by git rev-parse)

    View Slide

  10. Cartfile.private
    Same format as the Cartfile.
    Dependencies that your project needs that aren’t
    necessary for it to be used.
    These are not shared upstream.
    For example; things you need for testing.

    View Slide

  11. Demo
    Using Carthage

    View Slide

  12. carthage update
    Resolves dependencies and builds them

    View Slide

  13. carthage help update
    [--configuration Release]
    the Xcode configuration to build (ignored if --no-build option is present)
    [--platform all]
    the platform to build for (ignored if --no-build option is present)
    [--verbose]
    print xcodebuild output inline (ignored if --no-build option is present)
    [--no-build]
    skip the building of dependencies after updating
    [--use-ssh]
    use SSH for downloading GitHub repositories
    [--use-submodules]
    add dependencies as Git submodules
    [--no-use-binaries]
    check out dependency repositories even when prebuilt frameworks exist (ignored if --no-build option is present)
    [--color auto]
    whether to apply color and terminal formatting (one of ‘auto’, ‘always’, or ‘never’)

    View Slide

  14. carthage bootstrap
    Uses Cartfile.resolved to build dependencies

    View Slide

  15. carthage build
    Just builds what you have already.
    This is useful if you are using submodules.

    View Slide

  16. Demo
    Writing a Framework for Carthage

    View Slide

  17. Writing modules
    4 Share your build schemes
    4 When writing a Foundation module, create a
    separate target for iOS and Mac (takes some
    tweaking, but it can be done).

    View Slide

  18. !

    View Slide

  19. When things go wrong
    Because they will!
    - Check what compiler you are using with xcode-select
    -p
    - fix your build with carthage build --no-skip-current,
    build the scheme to see more detailed errors.
    - Blitz Carthage folder and Cartfile.resolved
    - Blitz the cache at ~/Library/Caches/carthage
    - Bitcode!

    View Slide

  20. When it all goes completely wrong!
    Because it will!

    View Slide

  21. When it all goes completely wrong!
    Because it will!
    - Change the Carthage update method to use
    submodules and not build.
    - Remove the linked frameworks.
    - Drag the dependency project files into your project
    and build it “old school”.

    View Slide

  22. So...

    View Slide

  23. View Slide

  24. View Slide

  25. Sorry!

    View Slide

  26. Simple

    View Slide

  27. Easy

    View Slide

  28. Carthage is simple, not easy.
    CocoaPods is easy, not simple.

    View Slide

  29. View Slide

  30. Git

    View Slide

  31. Thank You
    Abizer Nasir | @abizern | abizern.org

    View Slide