What is the “@exported” attribute in Swift

前端 未结 2 1292
暖寄归人
暖寄归人 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.

提交回复
热议问题