Corne Beukes
Corne Beukes

Reputation: 1999

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?

Upvotes: 5

Views: 7637

Answers (1)

Ken White
Ken White

Reputation: 125669

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.

Upvotes: 13

Related Questions