dart-lang / dart-lang/native

Symbol lookup for plugin fails on iOS with static linkage

Open
#902 1 comment 0 reactions 0 assignees View on GitHub
package:ffi
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

In order to use a [Google MLKit plugin](https://pub.dev/packages/learning_translate) in my Flutter App on iOS, I had to set `:linkage => :static` in my Podfile. After doing so, the [webcrypto plugin](https://pub.dev/packages/webcrypto) (which worked fine before) fails to lookup native boringssl symbols at runtime (it uses `DynamicLibrary.executable()` [here](https://github.com/google/webcrypto.dart/blob/master/lib/src/boringssl/lookup/lookup_symbol_flutter.dart#L26)).

Stack trace (in case it helps):
```
flutter: Unsupported operation: package:webcrypto cannot be used from scripts or `flutter test` unless `flutter pub run webcrypto:setup` has been run for the current root project.
flutter: #0 lookup. (package:webcrypto/src/boringssl/lookup/lookup_symbol_flutter.dart:47:5)
flutter: dart-lang/ffi#1 lookup (package:webcrypto/src/boringssl/lookup/lookup_symbol_flutter.dart:53:2)
flutter: dart-lang/ffi#2 lookup (package:webcrypto/src/boringssl/lookup/lookup_symbol_flutter.dart)
flutter: dart-lang/ffi#3 _cachedLookup (package:webcrypto/src/boringssl/lookup/lookup.dart:26:21)
flutter: dart-lang/ffi#4 _cachedLookup (package:webcrypto/src/boringssl/lookup/lookup.dart)
flutter: dart-lang/ffi#5 ssl (package:webcrypto/src/boringssl/lookup/lookup.dart:29:44)
flutter: dart-lang/ffi#6 ssl (package:webcrypto/src/boringssl/lookup/lookup.dart)
flutter: dart-lang/ffi#7 _aesCbcEncryptOrDecrypt (package:webcrypto/src/impl_ffi/impl_ffi.aescbc.dart:41:52)
```
So the original exception seems to appear [here](https://github.com/google/webcrypto.dart/blob/master/lib/src/boringssl/lookup/lookup_symbol_flutter.dart#L30-L31).

I already tried setting the Strip-Style to "Non-Global Symbols" in Xcode, as suggested in the [docs](https://docs.flutter.dev/development/platform-integration/c-interop#ios-symbols-stripped), but it doesn't make a difference.

**Note:** I also created an [issue](https://github.com/google/webcrypto.dart/issues/24) in the webcrypto plugin itself, but I'm not sure where it rather belongs and it currently blocks the release of our application, which is why I need to find a way to solve it fast. Hopefully here it's visible to more experts on this (I'm a noob with anything related to ffi on ios).

I'd really appreciate any help on this, as I'm completely stuck here. Please let me know if I need to provide more information.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.