-
-
Notifications
You must be signed in to change notification settings - Fork 909
Modernise swiftpm package manifest and enable development with Swift 4 manifest API #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Swift 3.1, swiftpm added support for evaluating environment variables in the package manifest. This enables us to remove the duplicated `.Package.swift` file, making it much easier to maintain the manifest.
Allows development using the swift 4 tools, allowing features like test-only dependencies and `swift run`.
Generated by 🚫 danger |
# Conflicts: # Rakefile
I confirmed that this successfully works with
👍 |
ikesyo
approved these changes
Jul 29, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 😎 👍
🎉 |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My primary goal with this PR was to try and find a configuration that would allow us to start using the Swift 4 version of the swiftpm package manifest. Why is this useful?
swift run
*Previously I thought that adopting Swift 4 package manager features would be a breaking change, but I just learned that it's possible to provide version-specific
Package.swift
files. So what this PR does is add a newPackage@swift-4.swift
manifest, that swiftpm happily picks up when using the Swift 4 compiler.However there's a bit of an issue here: we already have to maintain both
Package.swift
and.Package.test.swift
in order to define test-only dependencies, so adding this new manifest means that we're mainting 3 different manifest files. In order to resolve this, I've updated our minimum swift version to 3.1, which gives us the ability to read environment variables inside the package manifest. In this way, you can enable test dependencies under Swift 3 by setting theSWIFT_PACKAGE_TEST_Quick
variable to a truthy value. (I learned this technique from ReactiveSwift's package manifest.) This removes the need to maintain.Package.test.swift
.One more note — the swiftpm docs explicitly recommend against using the version-specific manifest feature to support the latest release of Swift:
While Swift 4 is still in beta, I believe it's safe to use the version-specific format. In fact, I tried the alternative of providing
Package.swift
andPackage@swift-3.swift
, and it unfortunately breaks the ability to use the Swift 3 package manager for development (importantly, it doesn't break anything for consumers of Quick, but the development loss is not ideal). Once Swift 4 is out of beta, I think we should rename the Swift 4 manifest to be the default, and provide aPackage@swift-3.swift
file for backwards compatibility until we decide to drop Swift 3 support altogether.* The new
swift run
command allows packages to easily ship command line tools, which users can run just by sayingswift run tool
. I'm pretty excited about this, and am currently exploring the possibility ofQuick
shipping a tool to make various automation tasks easier.