Skip to content

Feature/native api lint ffigen - #63734

Open
ayushgupta9906 wants to merge 1 commit into
dart-lang:mainfrom
ayushgupta9906:feature/native-api-lint-ffigen
Open

Feature/native api lint ffigen#63734
ayushgupta9906 wants to merge 1 commit into
dart-lang:mainfrom
ayushgupta9906:feature/native-api-lint-ffigen

Conversation

@ayushgupta9906

Copy link
Copy Markdown

Custom lint for OS-level API compatibility

Fixes #63618

Description

This PR introduces a custom analyzer plugin and annotation package to provide warnings and errors when generated ffigen bindings are incompatible with the user's project deployment targets.

iOS/macOS APIs have OS-versions defining when an API was introduced, deprecated, or obsoleted. When ffigen generates bindings for these APIs, developers need analyzer warnings if they call an API that requires a newer OS version than what their app currently targets.

Changes Included:

  • package:native_interop_annotation: Adds the @ExternalVersions annotation and ExternalVersion class. This allows ffigen to emit standard annotations specifying min, max, and deprecationMessage onto Dart elements.
  • package:native_api_lint: A standalone analyzer plugin hooked into the Dart analysis server that:
    • Dynamically reads the active workspace's deployment target (analysis_options.yaml, ios/Podfile, or ios/Runner.xcodeproj/project.pbxproj).
    • Emits api_not_available_on_min_target (WARNING) if the API requires a newer OS.
    • Emits api_obsoleted_on_min_target (ERROR) if the API was removed before the project's minimum target.
    • Emits api_deprecated_on_target (INFO) if the API is deprecated on the user's targeted OS version.
  • Added comprehensive unit testing with 100% pass rates across DeploymentTargetResolver, AnnotationReader, and VersionUtils.

Testing

  • Tested locally against the internal Dart SDK analyzer models.
  • Validated Podfile and pbxproj parsing with single quotes, double quotes, and leading spaces.
  • Verified graceful fallbacks when Xcode build configurations are missing or malformed.

@copybara-service

Copy link
Copy Markdown

Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at:

https://dart-review.googlesource.com/c/sdk/+/519800

Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly.

Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR).

Adds native_interop_annotation for @ExternalVersions and a custom analyzer plugin native_api_lint to warn when generated ffigen bindings are incompatible with the iOS/macOS minimum deployment target.

Fixes dart-lang#63618
@ayushgupta9906
ayushgupta9906 force-pushed the feature/native-api-lint-ffigen branch from 5ecaa34 to 9f8b8d8 Compare July 2, 2026 07:34
@copybara-service

Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/519800 has been updated with the latest commits from this pull request.

1 similar comment
@copybara-service

Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/519800 has been updated with the latest commits from this pull request.

@ayushgupta9906
ayushgupta9906 marked this pull request as ready for review July 3, 2026 04:24
@copybara-service

Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/519800 has been updated with the latest commits from this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[analyzer,interop] Custom lint for OS-level API compatibility for generated bindings to native APIs

1 participant