-
Notifications
You must be signed in to change notification settings - Fork 67
Don't generate ObjC bindings for deprecated APIs #1338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Did some investigation today. I can get information about whether an API is deprecated using
So all the deprecation info is there, but it's not quite as simple as just checking a flag that says whether the API is deprecated. We need to compare the deprecation version to some target version. There are a few options for where to get the target version, but I think the best approach is to just make it a config option. The answer is also going to depend on whether they're targeting ios or macos, so we should allow them to specify minimum target versions for both platforms and keep the method if it'd undeprecated on either. There's also the question of what to do if the target version isn't specified. I think it makes sense to keep the current behavior (generate all APIs) if the version isn't specified. But if the user is only interested in iOS, so leaves the macOS version unspecified, we should generate/skip the API based purely on the iOS availability info. This availability info can also be used for #300, using the Another option is |
We have two pieces of information:
Not only is the question what to do if the target version isn't specified, but also what the version should be that users publishing FFIgenned packages should specify. Maybe we should go for a range (not just a single target version) based on https://docs.flutter.dev/reference/supported-platforms and https://dart.dev/get-dart#system-requirements.
And then generate the method if it is available in at least one of those versions. If we provide a range as guidance to users publishing FFIgen-ed packages, we might as well default to it in the FFIgen config. Some more open questions:
|
@HosseinYousefi Is there any metadata on Java/Kotlin APIs on which Android version they require? Should we have something similar in JNIgen? |
Yes. I think there is an issue for it already. |
I think it's reasonable for ffigenned package authors to decide what minimum OS version they're targeting. It would be nice to have a general mechanism for this in the package's pubspec. But in most cases I'd expect the flutter plugin to be the thing that is doing the ffigenning anyway, or at least be owned by the same team (like how the webview_flutter plugin is backed by iOS and Android specific plugins).
Yeah, the runtime checks I'm talking about in #300 should be based on the runtime OS version. The decision this bug is talking about (whether to include the method at all) should be based on the versions that the package author wants to target.
We could maybe add this as a configurable option, but I don't think we should do it by default. Brian was seeing compile errors due to things pulled in as transitive dependencies of deprecated methods.
I was using "target version" as a shorthand for "minimum target version". We could also add a maximum target version, or use some version range syntax, and compare that to |
Apple APIs have deprecated annotations. If these are detectable using clang, we should not generate bindings for them.
If users need them, we can add a config option to generate them.
The text was updated successfully, but these errors were encountered: