Search code examples
iosflutterdartffidart-ffi

How to use .a file for iOS with Flutter FFI?


I have a rust project. Compiling it to .so for android, I'm able to run it with Android. I have also generated .a file for iOS and used instructions for this answer but it's throwing following error: Semantic Issue (Xcode): Use of undeclared identifier 'LibStackmatePlugin' /Users/mohitsingh/Desktop/myapp/ios/Runner/GeneratedPluginRegistrant.m:17:3.

GeneratedPluginRegistrant.m is as follows:

//
//  Generated file. Do not edit.
//

// clang-format off

#import "GeneratedPluginRegistrant.h"

#if __has_include(<libstackmate/LibStackmatePlugin.h>)
#import <libstackmate/LibStackmatePlugin.h>
#else
@import libstackmate;
#endif

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
  [LibStackmatePlugin registerWithRegistrar:[registry registrarForPlugin:@"LibStackmatePlugin"]];
}

@end

Is there something else that needs to be done?


Solution

  • The problem was with my pubspec.yaml file. It defined plugin as

          android:
            package: com.example.libstackmate
            pluginClass: LibstackmatePlugin
          ios:
            pluginClass: LibstackmatePlugin
    

    but in ios/app, plugin was defined as LibStackmatePlugin. Due to this name mismatch, I was getting this error. The error was resolved by updating ios pluginClass name in pubspec.yaml.