Skip to content
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

[retrofit_generator] Could not resolve annotation errors in generated iOS plugin files #741

Open
ashifali3147 opened this issue Feb 13, 2025 · 0 comments

Comments

@ashifali3147
Copy link

Description
I'm encountering errors when running retrofit_generator in my Flutter project. The build process fails with the following severe errors related to the generated iOS plugin files:

Error Logs

Built build_runner:build_runner.
[INFO] Generating build script completed, took 939ms
[INFO] Precompiling build script... completed, took 9.4s
[INFO] Building new asset graph completed, took 3.5s
[INFO] Checking for unexpected pre-existing outputs. completed, took 3.4s
[INFO] Generating SDK summary completed, took 12.7s
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/url_launcher_ios/pigeons/messages.dart:

line 1, column 959 of asset:package_name/example/ios/.symlinks/plugins/url_launcher_ios/pigeons/messages.dart: Could not resolve annotation for `abstract class UrlLauncherApi`.
  ╷
1 │ @HostApi()
  │ ^^^^^^^^^^
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/webview_flutter_wkwebview/pigeons/web_kit.dart:

line 1, column 9999 of asset:package_name/example/ios/.symlinks/plugins/webview_flutter_wkwebview/pigeons/web_kit.dart: Could not resolve annotation for `abstract class URLRequest extends NSObject`.
  ╷
1 │ @ProxyApi(swiftOptions: SwiftProxyApiOptions(name: 'URLRequestWrapper'))
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/shared_preferences_foundation/pigeons/messages.dart:

line 1, column 204 of asset:package_name/example/ios/.symlinks/plugins/shared_preferences_foundation/pigeons/messages.dart: Could not resolve annotation for `abstract class LegacyUserDefaultsApi`.
  ╷
1 │ ┌ @ConfigurePigeon(PigeonOptions(
2 │ │   dartOut: 'lib/src/messages.g.dart',
3 │ │   dartTestOut: 'test/test_api.g.dart',
4 │ │   swiftOut:
5 │ │       'darwin/shared_preferences_foundation/Sources/shared_preferences_foundation/messages.g.swift',
6 │ │   copyrightHeader: 'pigeons/copyright_header.txt',
7 │ └ ))
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/package_info_plus/example/integration_test/package_info_plus_web_test.dart:

line 1, column 548 of asset:package_name/example/ios/.symlinks/plugins/package_info_plus/example/integration_test/package_info_plus_web_test.dart: Could not resolve annotation for `void main()`.
  ╷
1 │ @GenerateMocks([http.Client, ui_web.AssetManager])
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/url_launcher_ios/test/url_launcher_ios_test.dart:

line 1, column 703 of asset:package_name/example/ios/.symlinks/plugins/url_launcher_ios/test/url_launcher_ios_test.dart: Could not resolve annotation for `void main()`.
  ╷
1 │ @GenerateMocks(<Type>[UrlLauncherApi])
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/connectivity_plus/test/connectivity_plus_linux_test.dart:

line 1, column 379 of asset:package_name/example/ios/.symlinks/plugins/connectivity_plus/test/connectivity_plus_linux_test.dart: Could not resolve annotation for `void main()`.
  ╷
1 │ @GenerateMocks([NetworkManagerClient])
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.dart:

line 1, column 673 of asset:package_name/example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.dart: Could not resolve annotation for `void main()`.
  ╷
1 │ ┌ @GenerateMocks(<Type>[
2 │ │   WKHTTPCookieStore,
3 │ │   WKWebsiteDataStore,
4 │ └ ])
  ╵
[SEVERE] retrofit_generator on example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.dart:

To Reproduce

  1. Run flutter pub get
  2. Execute dart pub run build_runner build --delete-conflicting-outputs
  3. The errors appear during code generation

Expected behavior
The code generation should complete successfully without annotation resolution errors.

Environment

[✓] Flutter (Channel stable, 3.29.0, on macOS 12.7.6 21H1320 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3)
[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    ! Flutter recommends a minimum Xcode version of 15.
      Download the latest version or update via the Mac App Store.
    ! CocoaPods 1.12.1 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] Android Studio (version 2024.2)
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
[✓] VS Code (version 1.96.4)
[✓] Connected device (4 available)
[✓] Network resources

Additional context

  1. This issue prevents me from building the iOS app.
  2. Sometimes, similar annotation resolution errors appear on Linux and Windows as well.
  3. Deleting .symlinks, running flutter clean, and regenerating the build files didn't resolve the issue.
  4. The issue seems to be related to Pigeon annotations in generated files, possibly affecting retrofit_generator or how the Flutter plugins interact.
  5. I have tried upgrading/downgrading dependencies, but the issue persists.
  6. I am using retrofit_generator: ^9.1.9 and build_runner: ^2.4.15
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

No branches or pull requests

1 participant