Just for a bit of fun I thought I would attempt to get flutter and nim working together. Why? Because flutter is dart and it builds to js on devices and is a JIT on MacOS, Linux and Windows.
The biggest problem is lack of documentation probably more on the Flutter ffi side but also on the nim side (with some crazy exceptions). So I thought I would document it here for people to at least get Android going and then I think following along iOS shouldn't be much harder.
So I started with the sample project here (NB: If using linux don't "snap" flutter. Pull the tar ball and install it): https://docs.flutter.dev/development/platform-integration/c-interop and got this working on Android.
Seemed simple enough. On to the next thing: Created a simple nim file which add's at the top level of the project in a nim directory: proc add(x, y: cint): cint {.cdecl, exportc, dynlib. } = x + y
Now for the hard part (or at least what is not explained), flutter actually builds for 4 android platforms (arm / intel in 32 / 64 mode). So we need create the 4 platform libraries: One of the command looks like nim c -c --cpu:arm --noMain --header:add.h --nimCache:../android/Classes/armeabi-v7a add.nim
Then change the -cpu to the other 3 and also the output location: arm armeabi-v7a arm64 arm64-v8a i386 x86 amd64 x86_64
So the simple CMakeLists.txt file in the example needs to be able to handle the new directories so you need to add all your classes with the Android build variable in it: ${ANDRIOD_ABI} and add all the generated file. Currently I am also copying in nimbase.h into those new directories until I learn CMake a little better.
Update the flutter code to reference your new method eg: native_add -> add
flutter run (with android selected). Hopefully it all builds.
Provided you get the cpu settings right and edit the correct build files I see no issue with having a fully functional cross platform app, with native performance where it counts. Yes it is in two languages, but flutter/dart is great for front end development (I just don't like the JIT and JS generation for high CPU code). I will try to publish a more detailed explanation somewhere if there is interest.
I also need to investigate if there is a way to roll the nim commands into the flutter build to generate the c files as needed. But just happy this works.
If you want to sign-up to be notified of the cross-platform UI kit, you can now sign-up: https://nexus-soft.carrd.co/
The initial back-end SDK is for Nim.