Given a current very concrete issue where certain base-level functionality is only available from certain "development targets" onwards (Make Host NSUnimplemented for Android by ephemer · Pull Request #2439 · apple/swift-corelibs-foundation · GitHub), it'd be great to allow devs to specify the minimum Android platform level they intend to target with their apps.
The most natural dev-facing API for this would be to hook into the existing #if available
API, i.e.:
#if available(Android 24, *)
doSomethingNice()
#else
NSUnimplemented()
#endif
I'm not 100% sure of the best way to achieve this, but it does need to be determined at compile time (to avoid non-existent symbols landing in the output binaries, which is impossible to work around on ELF). So it should probably end up as a compiler flag on swiftc
to mirror iOS deployment target flags.
For example: swiftc -some -flags -mmin-android-sdk-version=21
. That naming is based on how Android Studio calls it (minSdkVersion
) but I'm not so much set on the name as much as I am on the functionality behind it.
Would be great to hear thoughts from any other Swift-Android devs on this! @ColemanCDA @compnerd @johnno1962 @Gonzalo_Larralde @janek
Also, because this pitch would be a change to swiftc
, it'd be good to get some guidance and input from any interested core devs, @jrose?