First-Class Swift API for Objective-C Frameworks
In Objective-C, it’s possible to store a block as an
id
type, e.g. in a collection likeNSDictionary<String *, id>
. However, that’s a trap. If we store a Swift closure in the imported dictionary type, it will crash at the time we access the value.There is a workaround, but it has to be done on the Swift side. Declare the closure type with the
@convention(block)
and use it as a type[…][…]
The non-system framework Objective-C
NSUInteger
is imported asUInt
. That’s not very consistent with the Swift concept of having anInt
as the ultimate integer type. The conversation about ifNSUInteger
should be automatically imported as anInt
is already older than a year, and we’re still looking for a better solution in this area.[…]
API Notes is a textual file with a set of metadata interpreted by Swift’s Clang Importer without the need to rebuild the binary.
[…]
@_exported
will make an imported module re-exported as if the imported symbols were part of the intermediate module. The intermediate module is logically placed between two other modules, which is why it’s called an overlay framework: It overlays the@_exported
modules.