Is the documentation (and language support) for C sugaring better these days? If so, where can I find it?
I'm trying to make GDAL accessible from Swift via SPM. My attempt so far has failed in the link stage (
swift run of my little test app results in "ld: warning: Could not find or use auto-linked library 'gdal'", even though the lib is in
/usr/local/lib. I tried setting
DYLD_FALLBACK_LIBRARY_PATH, as neither path variable was set in my environment, but it didn't help).
But it does compile. Unfortunately, a C function like this:
const char* GDALVersionInfo(const char* pszRequest)
func GDALVersionInfo(_ inS: UnsafePointer<Int8>) -> UnsafePointer<Int8>
Is there a way to make that look like
func GDALVersionInfo(_ inS: String) -> String
without writing an explicit wrapper method? I can pass a string literal in the call without issue, but I have to create a
String to get one out:
let gv = String(cString: GDALVersionInfo("RELEASE_NAME"))
I know there are a ton of macros for sugaring C APIs that can be applied in the C header files, and the APINotes compiler hasn’t had a commit in over two years (that swift-clang project is archived, and searching the apple org on GitHub for "APINotesYAMLCompiler" didn't turn up anything more).
So yeah, I'm wondering what current best practices are in this regard.
C (and Python) libraries are going to remain crucial to Swift adoption for many years. I wish it weren’t so painful to use them.