Skip to content

Latest commit

 

History

History
123 lines (86 loc) · 3.41 KB

Development.md

File metadata and controls

123 lines (86 loc) · 3.41 KB

Development

This document contains information on building and testing the Swift Package Manager.

Using Swift compiler build script

The official way to build and test is using the Swift compiler build script. First, follow the instructions provided here and then run one of these commands:

macOS:
$ swift/utils/build-script -R --llbuild --swiftpm
Linux:
$ swift/utils/build-script -R --llbuild --swiftpm --xctest --foundation --libdispatch

This will build compiler and friends in build/ directory. It takes about ~1 hour for the inital build process. However, it is not really required to build the entire compiler in order to work on the Package Manager. A faster option is using a snapshot from swift.org.

Using trunk snapshot

  1. Download and install latest Trunk Development snapshot.

  2. Run the following command depending on your platform.

    macOS

    $ export TOOLCHAINS=swift
    # Verify that we're able to find the swift compiler from the installed toolchain.
    $ xcrun --find swift
    /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift

    Linux

    $ export PATH=/path/to/swift-toolchain/usr/bin:"${PATH}"
    # Verify that we're able to find the swift compiler from the installed toolchain.
    $ which swift
    /path/to/swift-toolchain/usr/bin/swift
  3. Building the Swift Package Manager.

    $ cd swiftpm
    $ Utilities/bootstrap

    This command will build the Package Manager inside .build/ directory. Run the bootstrap script to rebuild after making a change to the source code.

    You can also use the built binaries: swift-build, swift-package, swift-test, swift-run.

    Example:

    $ cd /tmp && mkdir hello && cd hello
    $ /path/to/swiftpm/.build/x86_64-apple-macosx10.10/debug/swift-package init
    $ /path/to/swiftpm/.build/x86_64-apple-macosx10.10/debug/swift-build
  4. Testing the Swift Package Manager.

    $ Utilities/bootstrap test --test-parallel

    Use this command to run the tests. All tests must pass before a patch can be accepted.

Self-hosting

It is possible to build the Package Manager with itself. This is useful when you want to rebuild just the sources or run a single test. Make sure you run the bootstrap script first.

$ cd swiftpm

# 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

Note: If you make any changes to PackageDescription or PackageDescription4 target, you will need to rebuild using the bootstrap script.

Developing using Xcode

Run the following command to generate a Xcode project.

$ Utilities/bootstrap --generate-xcodeproj
generated: ./SwiftPM.xcodeproj
$ open SwiftPM.xcodeproj

Note: If you make any changes to PackageDescription or PackageDescription4 target, you will need to regenerate the Xcode project using the above command.

Running the performance tests

Running performance tests is a little awkward right now. First, generate the Xcode project using this command.

$ Utilities/bootstrap --generate-xcodeproj --enable-perf-tests

Then, open the generated project and run the PerformanceTest scheme.