Let's add #if available(Android ?, *)

Hi @millenomi, thanks for your input on this!

If it's possible to "weakly link" and make a shim that only works in case the symbol exists, that'd be my preferred outcome as well of course. From what I understand thought that's only possible by using dlopen at runtime as you suggest, which might well be impossible on Android for this use-case:

  1. dlopening system libraries (anything from /system/lib(64)) is a fatal exception on Android 7.0+
  2. I actually have no idea which library we'd be dlopening here anyway (is getifaddrs provided by the C stdlib / runtime?). On Android > 5.0 Foundation "just works" without linking anything else at runtime.

So on platforms where the API doesn't exist, we could dlopen some system library (if you can tell me which one), but we already know that the symbol won't be there. And on platforms where we know it does exists, we can't use this method.

Is there no compile-time availability check at all, e.g. for Mac or for iOS? I still think that's the only way we'll be able to get around this, even if it has the unfortunate consequence of this API being unavailable unless Foundation is explicitly compiled for a higher Android platform level.