Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[pigeon] argument is neither an Objective-C object nor a block type #93525

@gianlucaparadise

Description

@gianlucaparadise

Steps to Reproduce

  1. Define an enum YourEnum
  2. Define a class YourObject with a Map<YourEnum?,String?> field
  3. Define a pigeon API with a method that takes YourObject as input
  4. Run pigeon to generate the code
  5. Run flutter build ios
  6. Error: Xcode can't build because of the enum as key of Map

You can also check this repository with a sample app:

  1. Clone the repo
  2. Run flutter build ios

Expected results: I expected to use a Map with enum as key

Actual results: The Map generates a build error in Xcode

Code sample

Pigeon API definition:

enum MessageKey {
  title,
  subtitle,
  description,
}

class Message {
  int? id;
  Map<MessageKey?, String?>? additionalProperties;
}

@HostApi()
abstract class HostApiBridge {
  void sendMessage(Message message);
}

A working sample is available in this repository.

Logs
Xcode's output:
↳
    In file included from
    /Users/your.name/mydev/pigeon_issue_example/ios/Runner/HostApi.m:3:
    /Users/your.name/mydev/pigeon_issue_example/ios/Runner/HostApi.h:21:53: error: type
    argument 'MessageKey *' (aka 'enum MessageKey *') is neither an Objective-C object nor a block type
    @property(nonatomic, strong, nullable) NSDictionary<MessageKey *, NSString *> * additionalProperties;
                                                        ^~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Flutter Analyze:

Analyzing pigeon_issue_example...                                       
No issues found! (ran in 2.6s)

Flutter Doctor:

[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6.1 20G224 darwin-x64, locale en-GB)
    • Flutter version 2.5.2 at /Users/gianluca.paradiso/flutter-sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 3595343e20 (6 weeks ago), 2021-09-30 12:58:18 -0700
    • Engine revision 6ac856380f
    • Dart version 2.14.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/gianluca.paradiso/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/gianluca.paradiso/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.28.0

[✓] Connected device (2 available)
    • Nexus 5X (mobile) • 02628c9c66bfd34f • android-arm64  • Android 8.1.0 (API 27)
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 95.0.4638.69

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions