[swift-evolution] [Draft] Adding a Build Configuration Import Test

Erica Sadun erica at ericasadun.com
Wed Mar 23 06:54:35 CDT 2016


> On Mar 23, 2016, at 12:59 AM, Pierre Monod-Broca <pierremonodbroca at gmail.com> wrote:
> 
> My guess is most often one will want to import exactly what one is testing (Brent example) but I guess it would be very handy to do something like
> 
> #if canImport(Foo)
>    import Foo.Bar as FooBar
> #endif
> 
> In this case both form would be relevant.

`import as ` does not fall under the scope of this proposal. I have been already discussing it
as part of an existing issue about package name conflicts on -build-dev, with the understanding
that this portion would have to be raised in -evolution. It's on my list for separate pitching.
An early draft is here: https://gist.github.com/erica/c6553a5f6f35e7462074 <https://gist.github.com/erica/c6553a5f6f35e7462074>, and the most
likely pathway would something like:

1. No change in the originating package description.

import PackageDescription

let package = Package(
    name:   "SwiftString",
)

2. No change in the consuming package description.

import PackageDescription
let package = Package (
    name: "myutility",
    dependencies: [
       .Package(url: "https://github.com/erica/SwiftString.git <https://github.com/erica/SwiftString.git>",
	        majorVersion: 1),
       .Package(url: "https://github.com/nudas/SwiftString.git <https://github.com/nudas/SwiftString.git>",
	        majorVersion: 1),
       .Package(url: "http://github.com/erica/SomeStringOtherPackage.git <http://github.com/erica/SomeStringOtherPackage.git>",
                majorVersion: 1), // just throwing some package in there
    ],
)

3. When unpacking, SwiftPM detects name overlap, automatically uses reverse domain name for unpacking

In the current Swift PM: 
    fatal: destination path '/home/erica/Work/test/Packages/SwiftString' already exists and is not an empty directory.

Instead:
* Would unpack into com.github.erica.SwiftString and com.github.nudas.SwiftString, automatically reversing the url
* From Swift files, since "import: SwiftString" allow import as erica.SwiftString, github.erica.SwiftString, or com.github.erica.SwiftString

4. Propose separately, "import as" as a language enhancement.

-- E

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160323/f0f402ba/attachment.html>


More information about the swift-evolution mailing list