The specific problem you're hitting is that in glibc the DIR type is opaque: that is, the C header file does not express the layout of the type, only that it exists. In C this has no particular impact at the type level, you just can't dereference the pointer or stack-allocate a value of it. In Swift, however, it entirely changes the type. The reason you're hitting this is that the type is not opaque on Darwin.
In general Swift does not attempt to keep libc types the same across systems (which is good, as it'd be an impossible task). For you, you can either use a typealias to specify the type for each system, or you can convert to OpaquePointer and back on all systems.
Thanks Lukasa.
I saw it was an OpaquePointer? but I didn't think at first I could just try to convert it to that.
I'll try that: typealias it or convert to OpaquePointer.
Alternatively, you could use FileManager for this. While Foundation isn’t perfect on non-Apple platforms, it’s more than capable of iterating a directory (-: