Compilation constants
Before you build your app, you choose the platform or platforms on which it will run. You can build apps for Windows, Linux, and Mac as desktop, console, web. Additionally, you can build for iOS. While programming, you can selectively enable or disable sections of your code that are valid only for particular platforms by using compilation constants.
Compilation constants
The compilation constants tell you information about the platform on which the app is running. When used with conditional compilation you can specify blocks of source code to include or exclude for specific platforms.
These are the some of the compilation constants:
DebugBuild: True when the app is running in Debug mode
Target32Bit: True when running as a 32-bit app.
Target64Bit: True when running as a 64-bit app.
TargetARM: True when the app is running on an ARM-based processor.
TargetConsole: True for console apps.
TargetDesktop: True for desktop apps.
TargetiOS: True for iOS apps.
TargetLinux: True when the app is running on Linux. This is True regardless of whether Linux itself is 32-bit or 64-bit.
TargetMacOS: True when running on macOS.
TargetWeb: True for web apps.
TargetWindows: True when the app is running on Windows.
Targetx86: True when the app is running on an x86-based processor.
For the complete list, refer to Compiler Category.
These constants are automatically set to either True or False depending on the platform being compiled. You can use conditional compilation commands to use specific code like this:
' Saving Preferences
#If TargetWin32 Then
' Use Registry
#ElseIf TargetMacOS Then
' Use plist
#ElseIf TargetLinux Then
' Use XML
#ElseIf TargetiOS Then
' Use JSON
#EndIf
Versions
You can also check the version of Xojo being used with the XojoVersion and XojoVersionString constants. These two constants can be used to block out code that is not compatible with older (or newer versions) of Xojo.