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

Contributing to SwiftPM

Contributing to SwiftPM

Slides introducing contributing to the Swift Package Manager at try! Swift San Jose 2018.

David Hart

June 08, 2018
Tweet

More Decks by David Hart

Other Decks in Programming

Transcript

  1. No reason to panic 4 96.5%1 Swift (no C++) 4

    Small codebase: ≈ 35k LOC 4 Well documented & tested 4 Awesome & helpful community 1 2.9% Python, 0.4% Shell, 0.1% C, 0.1% Objective-C
  2. Goal 4 Learn about SwiftPM 4 Discover how i ts

    made 4 Choose a Starter Task 4 Fix it 4 Open a Pull Request
  3. Create a package $ mkdir MyPackage $ cd MyPackage $

    swift package init --type library/executable $ swift build $ swift test
  4. Define Dependencies import PackageDescription let package = Package( name: "MyPackage",

    dependencies: [ .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "1.0.0") ], targets: [ .target(name: "Foo", dependencies: ["SwiftyJSON"]), ] )
  5. swift package $ swift package --help OVERVIEW: Perform operations on

    Swift packages SUBCOMMANDS: clean Delete build artifacts edit Put a package in editable mode generate-xcodeproj Generates an Xcode project init Initialize a new package resolve Resolve package dependencies show-dependencies Print the resolved dependency graph unedit Remove a package from editable mode update Update package dependencies
  6. swift build $ swift build --help OVERVIEW: Build sources into

    binary products OPTIONS: --configuration, -c Build with configuration (debug|release) --product Build the specified product --target Build the specified target
  7. swift test $ swift test --help OVERVIEW: Build and run

    tests OPTIONS: --configuration, -c Build with configuration (debug|release) --filter Run test cases matching regular expression --parallel Run the tests in parallel.
  8. swift run $ swift run --help OVERVIEW: Build and run

    an executable product USAGE: swift run [options] [executable [arguments ...]] OPTIONS: --configuration, -c Build with configuration (debug|release)
  9. Setup 1. Install Xcode 10 & latest Swift trunk snapshot.

    2. Run the following commands: $ export TOOLCHAINS=swift $ xcrun --find swift 3. Fork and clone SwiftPM on GitHub. 4. Build the Swift Package Manager: $ Utilities/bootstrap
  10. Commands # Rebuild just the sources. $ .build/x86_64-apple-macosx10.10/debug/swift-build # Run

    a single test. $ .build/x86_64-apple-macosx10.10/debug/swift-test --filter BasicTests.GraphAlgorithmsTests/testCycleDetection # Run all tests. $ Utilities/bootstrap test --test-parallel # Generate Xcode project $ .build/x86_64-apple-macosx10.10/debug/swift-package generate-xcodeproj
  11. Level 2 4 SR-6277 4 SR-7073 4 SR-7074 4 SR-7279

    4 SR-7823 4 SR-7824 4 SR-7830