LtbLightning / bdk-flutter

Bitcoin Development Kit - Flutter Package
MIT License
63 stars 28 forks source link

iOS, Rust exception in app with flavors #52

Closed awaik closed 1 year ago

awaik commented 1 year ago

Hi!

When I try to run the example app under iOS I got an error

Code that returns the error

final mnemonic =
        await Mnemonic.fromString('puppy interest whip tonight dad never sudden response push zone pig patch');

Error

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'store_dart_post_cobject': dlsym(RTLD_DEFAULT, store_dart_post_cobject): symbol not found
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70)
#1      RustWire._store_dart_post_cobjectPtr (package:bdk_flutter/src/generated/bindings.dart:1714:76)
#2      RustWire._store_dart_post_cobjectPtr (package:bdk_flutter/src/generated/bindings.dart)
#3      RustWire._store_dart_post_cobject (package:bdk_flutter/src/generated/bindings.dart:1716:41)
#4      RustWire._store_dart_post_cobject (package:bdk_flutter/src/generated/bindings.dart)
#5      RustWire.store_dart_post_cobject (package:bdk_flutter/src/generated/bindings.dart:1708:12)
#6      StoreDartPostCObjectExt.storeDartPostCObject (package:flutter_rust_bridge/src/ffi/io.dart:18:5)
#7      FlutterRustBridgeBase._setUpRustToDartComm (package:flutter_rust_bridge/src/basic.dart:60:11)
#8      new FlutterRustBridgeBase (package:flutter_rust_bridge/src/basic.dart:28:5)
#9      new RustPlatform (package:bdk_flutter/src/generated/bindings.dart:1248:44)
#10     new RustImpl (package:bdk_flutter/src/generated/bindings.dart:19:59)
#11     loaderApi (package:bdk_flutter/src/utils/loader.dart:9:19)
#12     loaderApi (package:bdk_flutter/src/utils/loader.dart)
#13     Mnemonic.fromString (package:bdk_flutter/src/root.dart:783:25)
#14     _MyAppState.createDescriptorSecret (package:first_app/main.dart:46:24)
#15     _MyAppState.restoreWallet (package:first_app/main.dart:36:11)
#16     _MyAppState.initState (package:first_app/main.dart:24:5)
#17     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5101:55)
#18     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4944:5)
#19     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3953:16)
#20     Element.updateChild (package:flutter/src/widgets/framework.dart:3682:18)
#21     RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1176:16)
#22     RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1145:5)
#23     RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1092:18)
#24     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2682:19)
#25     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1091:13)
#26     WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:926:7)
#27     WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:906:7)
#28     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#29     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#30     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#31     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

How to reproduce the error

  1. example app
  2. create a scheme (flavor) under ios, two gifs: https://miro.medium.com/max/1400/1*tctD2CuUZuCV4FcFIXXddw.gif https://miro.medium.com/max/1400/1*XsDo_Kv4UPiS-Qeix9YEEA.gif
  3. run this flavor flutter run --flavor dev
BitcoinZavior commented 1 year ago

@awaik Flavors provide a way for building different versions of the app from the same code base with different build configurations. Unfortunately, when using external modules it may not be as simple as adding the flavors from XCode. For example, when using firebase more configuration is required: https://codewithandrea.com/articles/flutter-flavors-for-firebase-apps/#:~:text=What%20are%20Flutter%20Flavors%3F,app%20icons%20for%20each%20configuration.

This is a high level reference, especially for ios schema updates.

The gradle build and project.pbxproj as well as ios schema might need to be configured correctly for different flavors.

I will look into this when I get a chance, however, this falls under application-side configuration.

Also, instead of flavors, you can use test flight for your test version of the app and then make a live config and test that on test flight too before releasing it to the app store. For Android, there are Alpha and Beta options available to have different test and live configurations for testing.

awaik commented 1 year ago

@BitcoinZavior Thank you for the detailed answer.

Under Android the package works well with flavors.

For ios, yes, I made different settings for Firebase. But the reason for this setting is not the error in an external module, but for different key configurations. Without these settings Firebase code works well, just can't connect to the backend.

We use flavors to create different apps with one code base, so we can't give up on them.

I guess, there is some setting on the external modules path or something like this. It would be great if you will have a chance to check.

Thank you!

awaik commented 1 year ago

Maybe this would help? https://github.com/fzyzcjy/flutter_rust_bridge/issues/250

BitcoinZavior commented 1 year ago

@awaik Would you be able to test flavors with hotfixes-flutter-flavors branch and see if it builds?

awaik commented 1 year ago

@BitcoinZavior Sure, will test tomorrow. Thanks!

awaik commented 1 year ago

@BitcoinZavior Yep, it works - the issue is fixed.

BitcoinZavior commented 1 year ago

Thanks for checking, this will make it into the next release