dart-native / codegen

Generator for dart_native bindings. Codegen can transform native SDK to Flutter plugin.
BSD 3-Clause "New" or "Revised" License
79 stars 3 forks source link

Huge no. of errors running code gen on AVFoundation #44

Open bsutton opened 3 years ago

bsutton commented 3 years ago

I'm trying to generate the dart_native dart code for the ios AVFoundation framework.

When I run code gen it appears to be generating all of the files however it is generating a large no of errors (attached file).

As I'm writing this I'm also waiting for it to complete. It appears to have generated all of the files but is now sitting churning cpu and not doing much (15+ minutes)

The errors and generated code.

error.zip

code.zip

yulingtianxia commented 3 years ago

Codegen is a tool for generating dart bindings for native APIs. You can use codegen with file or folder path. But it's still under development and may have errors when processing complicated grammar. We are working hard on it.

You can also use dart_native without codegen. For example:

Here is OC code:

@interface RuntimeStub : NSObject
- (BOOL)fooBOOL:(BOOL)b;
@end

You can write your dart binding code instead of using codegen:

class RuntimeStub extends NSObject {
  RuntimeStub([Class isa]) : super(isa ?? Class('RuntimeStub'));

  RuntimeStub.fromPointer(Pointer<Void> ptr) : super.fromPointer(ptr);

  bool fooBOOL(bool b) {
    return perform(SEL('fooBOOL:'), args: [b]);
  }
}

Last, call native API using Dart:

RuntimeStub stub = RuntimeStub();
bool resultBool = stub.fooBOOL(false);
print('fooBool result:$resultBool');
yulingtianxia commented 3 years ago

We had fixed the performance issue since 1.2.0