diff --git a/example/objective_c/config.yaml b/example/objective_c/config.yaml index b44cc690..3a76517e 100644 --- a/example/objective_c/config.yaml +++ b/example/objective_c/config.yaml @@ -12,4 +12,4 @@ headers: entry-points: - '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioPlayer.h' preamble: | - // ignore_for_file: camel_case_types, non_constant_identifier_names, unused_element, unused_field, return_of_invalid_type, void_checks, annotate_overrides, no_leading_underscores_for_local_identifiers, library_private_types_in_public_api + // ignore_for_file: camel_case_types, non_constant_identifier_names, unused_element, unused_field, void_checks, annotate_overrides, no_leading_underscores_for_local_identifiers, library_private_types_in_public_api diff --git a/lib/src/code_generator/objc_block.dart b/lib/src/code_generator/objc_block.dart index 883acd73..ba028d66 100644 --- a/lib/src/code_generator/objc_block.dart +++ b/lib/src/code_generator/objc_block.dart @@ -92,8 +92,14 @@ $voidPtr $registerClosure(Function fn) { s.write(', ${params[i].type.getDartType(w)} ${params[i].name}'); } s.write(') {\n'); - s.write(' ${isVoid ? '' : 'return '}$closureRegistry[' - 'block.ref.target.address]!('); + s.write(' ${isVoid ? '' : 'return '}'); + s.write('($closureRegistry[block.ref.target.address]'); + s.write(' as ${returnType.getDartType(w)} Function('); + for (int i = 0; i < params.length; ++i) { + s.write('${i == 0 ? '' : ', '}${params[i].type.getDartType(w)}'); + } + s.write('))'); + s.write('('); for (int i = 0; i < params.length; ++i) { s.write('${i == 0 ? '' : ', '}${params[i].name}'); } diff --git a/test/native_objc_test/setup.dart b/test/native_objc_test/setup.dart index 5eff12cc..8e74d878 100644 --- a/test/native_objc_test/setup.dart +++ b/test/native_objc_test/setup.dart @@ -119,6 +119,8 @@ Future clean(List testNames) async { } Future main(List arguments) async { + // Allow running this script directly from any path (or an IDE). + Directory.current = Platform.script.resolve('.').toFilePath(); if (!Platform.isMacOS) { throw OSError('Objective C tests are only supported on MacOS'); }