When building the driver in Swift 4.1+, one gets several deprecation warnings like this:
I am pretty sure that the new way will not work in 4.0, but we should confirm that. It seems that Xcode 10 + swiftenv's 4.0 are not playing nicely together and I can no longer build the driver with 4.0 locally to test myself...
Assuming it doesn't work with 4.0, we can fix these warnings by using inline version checks, that use the new way for Swift 4.1+. See _BSONKeyedDecodingContainer.allKeys for an example of an inline version check.
It appears that all of these cases involve an UnsafeMutablePointer<UnsafePointer<Int8>?> or an UnsafeMutablePointer<UnsafePointer<bson_t>?>, so we can likely accomplish this using 1-2 shared methods that handle freeing pointer pointers, rather than adding the conditional in every place.