20

I saw the use of @exported in this open source project, but didn't see it in Apple's documentation. What is this attribute and what does it do?

2 Answers2

16

This attribute officially does not exist. Unofficially, however, it is a way of opening a sub-framework's symbols into your own framework's scope and exporting them as though they were yours. For example, a testing framework might wish to declare an @exported XCTest somewhere so all it takes to use the framework is just import TestFramework.

Be warned, though the attribute is compatible with most swift versions and should compile fine, it will break code completion in creative ways on each individual build of Xcode - probably a big reason why it is not an official feature yet.

CodaFi
  • 43,043
  • 8
  • 107
  • 153
  • Great answer, love the discussion here: https://github.com/typelift/SwiftCheck/pull/114/files#r44612923 Thank you! – JAL Nov 12 '15 at 21:28
  • 1
    There have been on going discussion about it here https://forums.swift.org/t/exported-and-fixing-import-visibility/9415 – Shady Mostafa Aug 30 '19 at 12:42
0

According to this site:

exported : Apply this attribute to an import declaration to export the imported module, submodule, or declaration from the current module. If another module imports the current module, that other module can access the items exported by the current module.

Dharman
  • 30,962
  • 25
  • 85
  • 135
omaraguirre
  • 154
  • 5