[swift-users] Annotating C APIs without changing the original header files
geojay at gmail.com
Wed May 3 18:10:14 CDT 2017
I’m about to start on another big project with Swift on Android and would like to annotate that JNI headers as much as possible before I do: specifically I’d like to make _Nonnull and CF_SWIFT_NAME annotations to the headers found in a user's jni.h.
The question is: is it possible to annotate headers this without changing the original header files? Specifically I’m looking for an options that allows annotations in a separate file, probably one that is read when loading the package’s module.modulemap.
I’d like to distribute the annotations in a SwiftPM package that also exposes the original (hopefully annotated) headers. Up until now I’ve been using Swift to override methods in code, but this isn’t as clean or extensible and I fear it may have other (particularly performance) implications.
I guess the alternative would be to just maintain and distribute a modified version of jni.h with the annotations, but that would be a "last resort” option.
Thanks in advance,
More information about the swift-users