From 2c7d60cc1c1c523583a8746975062d30da3a22e6 Mon Sep 17 00:00:00 2001 From: wgh19 Date: Tue, 23 Apr 2024 16:08:05 +0800 Subject: [PATCH] update ios and macos --- lib/src/ffi.dart | 26 +++++++++++++++----------- macos/flutter_qjs.podspec | 1 - 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/src/ffi.dart b/lib/src/ffi.dart index d4a8127..3bf18d5 100644 --- a/lib/src/ffi.dart +++ b/lib/src/ffi.dart @@ -113,17 +113,21 @@ abstract base class JSRuntime extends Opaque {} abstract base class JSPropertyEnum extends Opaque {} -final DynamicLibrary _qjsLib = Platform.environment['FLUTTER_TEST'] == 'true' - ? (Platform.isWindows - ? DynamicLibrary.open('test/build/Debug/ffiquickjs.dll') - : Platform.isMacOS - ? DynamicLibrary.open('test/build/libffiquickjs.dylib') - : DynamicLibrary.open('test/build/libffiquickjs.so')) - : (Platform.isWindows - ? DynamicLibrary.open('flutter_qjs_plugin.dll') - : Platform.isAndroid - ? DynamicLibrary.open('libqjs.so') - : DynamicLibrary.process()); +final DynamicLibrary _qjsLib = () { + if (Platform.isMacOS || Platform.isIOS) { + return DynamicLibrary.open('flutter_qjs.framework/flutter_qjs'); + } + if (Platform.isAndroid) { + return DynamicLibrary.open('libqjs.so'); + } + if (Platform.isLinux) { + return DynamicLibrary.open('libflutter_qjs_plugin.so'); + } + if (Platform.isWindows) { + return DynamicLibrary.open('flutter_qjs_plugin.dll'); + } + throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); +}(); /// DLLEXPORT JSValue *jsThrow(JSContext *ctx, JSValue *obj) final Pointer Function( diff --git a/macos/flutter_qjs.podspec b/macos/flutter_qjs.podspec index 48d5097..79e4f3a 100644 --- a/macos/flutter_qjs.podspec +++ b/macos/flutter_qjs.podspec @@ -19,7 +19,6 @@ This plugin is a simple js engine for flutter using the `quickjs` project. Plugi s.platform = :osx, '10.11' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.vendored_libraries = 'build/Debug/libffiquickjs.dylib' s.prepare_command = 'sh ../cxx/prebuild.sh' s.swift_version = '5.0' end