Cross-Platform Development

From Xojo Documentation
Jump to: navigation, search

Using Target Flags

You can develop your application on one platform and compile it for any other platforms that Xojo supports. If your application will run on more than one platform, you can use the following global Boolean constants to determine which type of code is currently executing.


Boolean Constant Description
DebugBuild The application is running in debug mode, directly from the IDE.
RBVersion Returns the version of Xojo that was used to compile the app. You can use this in an expression that evaluates to True or False to enabled or disable code based on the version.
TargetBigEndian The compiled application is running on a machine and OS that uses the Big Endian byte ordering.
TargetCocoa New in 2010r3 The application is compiling or running on OS X Cocoa, which is the default for OS X applications.
TargetDesktop The application is compiling or running as a desktop app.
TargetLinux New in 5.5 The compiled application is running Linux code.
TargetLittleEndian The compiled application is running on a machine and OS that uses the Little Endian byte ordering.
TargetMachO New in 5.5 The compiled application is running on Mac OS X, running object code in the format for the Mach kernel.
TargetMacOS The compiled application is currently running Macintosh code, for either Cocoa or Carbon frameworks.
TargetWin32 The compiled application is currently running Win32 code.
Targetx86 The compiled application is currently running on x86 hardware, regardless of OS.

Conditional Compilation

If some of your code should be compiled only for a particular target platform (such as AppleScript-specific code or Declare statements), you can use #If statements to compile that code only for the appropriate platform. Use the following structure:


#If TargetBoolean
//OS-specific code
//included in built app
//only for target platform
#Else (optional) (optional code)

#ElseIf TargetBoolean //(optional)
//(optional) Other OS-specific code
#Endif
Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About