As part of my recent DelphiCon 2021 session, Multi-Platform Explorations using Delphi, FMX, Feeds, REST and More, my example code needed to use IFDEFs for some of the uses statements, variable definitions and code. This blog post contains an example of the use of defines when compiling for Windows (Win32/Win64), macOS, iOS and Android platforms. I also include screen shots of the sample output on each platform. You can download all of my talk’s sample projects using the session links above.
The simple Delphi FireMonkey application includes a TButton and a TMemo. In the Button’s OnClick event handler the code outputs information about the platform and the compiler defines for each platform.
[crayon-673f708434bf6771385884/]
Screen Grabs for Each Platform
Additional information can be found on the Delphi Wiki:
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Conditional_compilation_(Delphi)
Interested in building an app that supports Android and Windows? Try out the Windows IDE and make the most of it. Start the Free Trial here.