gtbluesky / onnxruntime_flutter

A flutter plugin for OnnxRuntime provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms.
MIT License
54 stars 13 forks source link

Failing to get instance on archived iOS bundles. #24

Open smilingjack10 opened 4 weeks ago

smilingjack10 commented 4 weeks ago

The plugin works perfectly when used on iOS applications that were build from flutter or Xcode, both in debug as in release mode. However, once packaged into an IPA in order to upload to the App Store the onnxruntime plugin cannot be found anymore. I tried forcing to link the library in Xcode but this didn't resolve anything. Also tried: cleaning the project both from Xcode and VSCode, create a new project, other physical device. Nothing helped. When I connect the console to my physical iOS device I get the following error:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'OrtGetApiBase': dlsym(RTLD_DEFAULT, OrtGetApiBase): symbol not found

0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33)

1 OnnxRuntimeBindings._OrtGetApiBasePtr (package:onnxruntime/src/bindings/onnxruntime_bindings_generated.dart:38)

2 OnnxRuntimeBindings._OrtGetApiBase (package:onnxruntime/src/bindings/onnxruntime_bindings_generated.dart)

3 OnnxRuntimeBindings.OrtGetApiBase (package:onnxruntime/src/bindings/onnxruntime_bindings_generated.dart)

4 new OrtEnv._ (package:onnxruntime/src/ort_env.dart:22)

5 OrtEnv._instance (package:onnxruntime/src/ort_env.dart:11)

6 inferSingleSequence (package:equifib_2/utils/onnx_runtime.dart)

7 _EcgScreenState.onDisconnectPressed (package:equifib_2/screens/ecg_screen.dart:412)

using plugin version 1.4.1, flutter 3.19.3, Xcode 15.4, target iOS 13. Not 100% sure if this is purely a bug of the onnxruntime plugin, but other cocoa pods dependent plugins don't have any problems. When looking at the linked frameworks in the IPA file I don't see the onnxruntime framework listed, but I'm not sure if this is normal or not?
gtbluesky commented 3 weeks ago

Try to set STRIP_STYLE = "non-global" in YourPorject.xcodeproj/project.pbxproj

smilingjack10 commented 3 weeks ago

Hi, Thank you for the quick response! Unfortunately, setting STRIP_STYLE="non-global" in the runner or pods Xcode project didn't help. However, adding STRIP_INSTALLED_PRODUCT = NO; under the build settings of the release version did. Thank you for pointing me in the right direction! I changed this in: ios/Runner.xcodeproj/project.pbxproj