What does `@_exported import ` do?

I'm looking at the source for SPM and I see @_exported import for some of the imports in TSCLibc. What does this do exactly?

Just re-export whatever you import, or import proxy/forwarding.

1 Like

Thanks for the response. So just to be clear, this would mean that if I had module Foo:

// Foo.swift

func foo() { ... }

And module Bar:

// Bar.swift

@_exported import Foo

And dependencies set up like so:

//Package.swift
...
    targets: [
        .library(name: "Foo"),
        .library(name: "Bar", dependencies: ["Foo"]),
        .library(name: "Baz", dependencies: ["Bar"]),
    ]
...

Then from inside Baz, I wold still be able to caall foo without importing Foo directly:

// Baz.swift

import Bar

foo() // imported from Foo via Bar

Is that correct?

3 Likes

Yes. But keep in mind that anything starting with an underscore isn’t finalized yet, so you should not rely on it being stable.

1 Like

bingo, you got it!