dart-native / dart_native

Write iOS&macOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
BSD 3-Clause "New" or "Revised" License
953 stars 79 forks source link

Problems initializing dart native for ios #39

Open relf108 opened 3 years ago

relf108 commented 3 years ago

We have the following unit test in example/test directory of a project:

import "package:test/test.dart";
import 'package:dart_native/dart_native.dart';
void main() {
  // Define the test
  test("Testing ffi implementation of AVAudioPlayer", () {
    runDartNative();
    // Arrange
    NSObject player = new NSObject(Class('NSObject'));
    // Asset
    expect(player.description, '');
  });
}

This is failing with the following error:

Connecting to VM Service at http://127.0.0.1:49354/kOZquTJPEHw=/ws
Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, RegisterDeallocCallback): symbol not found)
dart:ffi                                                      DynamicLibrary.lookup
package:dart_native/src/ios/common/callback_manager.dart      registerDeallocCallback
package:dart_native/…/common/callback_manager.dart:1
package:dart_native/src/ios/common/callback_manager.dart      registerDeallocCallback
package:dart_native/…/common/callback_manager.dart:1
runtimeLib
package:dart_native/…/common/library.dart:17
nativeGetClass
package:dart_native/…/runtime/native_runtime.dart:41
package:dart_native/src/ios/runtime/native_runtime.dart       nativeGetClass
package:dart_native/…/runtime/native_runtime.dart:1
_getClass
package:dart_native/…/runtime/class.dart:64
new Class
package:dart_native/…/runtime/class.dart:16
main.<fn>
test/avaudioplayer_test.dart:9

I should note I've added use_frameworks! to the podspec in the examples directory. Thanks in advance :)

yulingtianxia commented 3 years ago

@relf108 There is a BIG problem about testing plugins in Flutter: Native app/framework is NOT launched by unit test. Although we can use stubs instead of native code, but it's the opposite of what DartNative is trying to do.