Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sharplet
Copy link
Contributor

@sharplet sharplet commented Jul 12, 2017

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?

  • To set up the project to make it easier to start testing Swift 4 package manager features, like test-only dependencies and swift run*
  • To get us a step closer to migrating off the Swift 3 manifest format at some point in the future

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 new [email protected] 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 the SWIFT_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:

It is not expected the packages would ever use this feature unless absolutely necessary to support existing clients. In particular, packages should not adopt this syntax for tagging versions supporting the latest GM Swift version.

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 and [email protected], 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 a [email protected] 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 saying swift run tool. I'm pretty excited about this, and am currently exploring the possibility of Quick shipping a tool to make various automation tasks easier.

sharplet added 5 commits July 12, 2017 13:41
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`.
@QuickBot
Copy link

QuickBot commented Jul 12, 2017

1 Warning
⚠️ Big PR

Generated by 🚫 danger

@ikesyo
Copy link
Member

ikesyo commented Jul 29, 2017

I confirmed that this successfully works with

  • macOS, Xcode 8.3
  • macOS, Xcode 9 beta
  • Linux, Swift 3.1
  • Linux, 4.0-DEVELOPMENT-SNAPSHOT-2017-07-25-a

👍

Copy link
Member

@ikesyo ikesyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😎 👍

@ikesyo ikesyo merged commit a252243 into master Jul 29, 2017
@ikesyo ikesyo deleted the as-package-env branch July 29, 2017 06:50
@sharplet
Copy link
Contributor Author

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants