Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I handle platform specific code in a Delphi XE7 app meant for multiple platforms?

I want my project to compile to iOS and Android. What do I do with code that is meant for one platform and not the other? Is there some way to indicate to Delphi XE7 to ignore e.g. Android specific code (like invoking an intent) when compiling for iOS?

like image 473
Corne Beukes Avatar asked Oct 12 '14 16:10

Corne Beukes


1 Answers

There are predefined compiler directives for just this use:

{$IFDEF ANDROID}
// Android-specific code here
{$ENDIF}

{$IFDEF IOS}
// IOS specific code here
{$ENDIF}

{$IFDEF MACOS}
// OS X specific code here
{$ENDIF}

There is a list of all of the pre-defined compiler directives in the documentation.

like image 125
Ken White Avatar answered Oct 06 '22 10:10

Ken White