What is the “@exported” attribute in Swift

前端 未结 2 1291
暖寄归人
暖寄归人 2021-02-07 07:25

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条回答
  • 2021-02-07 07:45

    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.

    0 讨论(0)
  • 2021-02-07 07:57

    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.

    0 讨论(0)
提交回复
热议问题