vcl/fmx compatility in mistralAI.files.pas
mistralAI.files
is it possible to add a directive to use fmx
implementation
uses System.StrUtils, Rest.Json, System.Rtti, MistralAI.NetEncoding.Base64, {$ifdef fmx} fmx.Dialogs; {$else} Vcl.Dialogs; {$endif}
Thanks for the suggestion
I’m keeping the wrapper 100% UI-agnostic (no VCL or FMX in the core) to ensure:
- Separation of concerns: API logic ≠ UI.
- Portability & testing: works in VCL, FMX, console, services, etc., with no extra dependencies or bloat.
- Clean linking: avoids pulling in an unnecessary UI framework.
[!note] Embarcadero strongly advises against mixing VCL and FMX code in the same unit. A Delphi unit should be either VCL or FMX, but never both.
Recommended approach (on your side): create an adapter unit in your project that uses either VCL or FMX. Even cleaner: use callbacks/DI (the wrapper exposes OnLog, OnError, and your app plugs in VCL/FM X as needed). This keeps the wrapper platform-independent, and everyone can choose their preferred UI.
Thank for the feedback
My app is only fmx and target android, ios, windows
In the 2 mistralAI units : mistraAI.files.pas and mistralAI.httpx.pas there is reference to vcl (vcl.dialogs) in mistraAI.files.pas and reference with windows api ( Winapi.Windows, Winapi.ShellAP ) in misltralAI.httpx.pas in the uses part of the units. It was the reason of my remark. With these dependencies i can't compile for Android delphi 12.3
Honestly, we should have started with that and just told me I’d made a blunder ;)
I’ve removed the VCL.Dialogs unit, which definitely didn’t belong in MistralAI.Files.pas, and fixed the issue in MistralAI.Httpx.pas as well.
Version 1.3.1 has just been published. Feel free to grab it and let me know if you’re still having any issues compiling on Android.