In Apple's github for the Swift Package manager they use
import func POSIX.isatty
import func libc.strerror_r
import var libc.EINVAL
import var libc.ERANGE
import struct PackageModel.Manifest
source
There is also a file where the only code in it is @_exported
source
@_exported import func libc.fileno
Is this a Swift 3 feature? I can not find anywhere that you can import a type in the Swift documentation and nothing on @_exported
.
You can import only a specific part of a module, not a whole module:
Providing more detail limits which symbols are imported—you can specify a specific submodule or a specific declaration within a module or submodule. When this detailed form is used, only the imported symbol (and not the module that declares it) is made available in the current scope.
From Import Declaration
For example import func POSIX.isatty
will import function isatty
from module POSIX
instead of importing the whole module POSIX
(which is BIG).
The @_exported
attribute starts with an underscore. That means it's a private Swift attribute. Not a feature, an implementation detail.
In short, this attribute lets you export a symbol from another module as if it were from your module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With