How to check if an application is running on an iOS device or simulator in Delphi XE6

Based on this link Conditional Compilation (Delphi) CPUARM is conditional, if it should be false for Simulator and true for the device, the problem is that it does not work for me. I useDelphi XE6, iOS Simulator 7.1

This is my code.

    {$IFDEF CPUARM}
s := 'iOS device';
    {$ELSE}
s := 'iOS Simulator';
    {$ENDIF}

ps iOS Simulator runs on VMWare virtual machine.

+4
source share
2 answers

Checking for CPUARMis the right decision. The iOS compiled for the simulator are not ARM, they are actually x86. Just make sure your iOS code is using {$IFDEF IOS}:

{$IFDEF IOS}
  {$IFDEF CPUARM}
s := 'iOS device';
  {$ELSE}
s := 'iOS Simulator';
  {$ENDIF}
{$ENDIF}

Delphi uses the ARM compiler for iOS devices, but uses the x86 compiler for the iOS simulator.

Embarcadero DocWiki:

(Delphi) |

CPUARM DCCIOSARM ( iOS).

CPU386 CPUX86 DCCIOS32 (iOS-).

, DCCIOSARM.EXE DCCIOS32.EXE XE6, , :

DCCIOSARM.EXE:

**CPUARM**
DCC
NEXTGEN
AUTOREFCOUNT
WEAKINSTREF
WEAKINTFREF
WEAKREF
EXTERNALLINKER
NATIVECODE
POSIX
POSIX32
MACOS
MACOS32
**IOS**
VER270
CONSOLE
BCB
PIC
UNICODE
CONDITIONALEXPRESSIONS

DCCIOS32.EXE:

**CPU386**
**CPUX86**
DCC
NEXTGEN
AUTOREFCOUNT
WEAKINSTREF
WEAKINTFREF
WEAKREF
NATIVECODE
POSIX
POSIX32
MACOS
MACOS32
**IOS**
ALIGN_STACK
UNDERSCOREIMPORTNAME
PC_MAPPED_EXCEPTIONS
ASSEMBLER
VER270
CONSOLE
BCB
PIC
UNICODE
CONDITIONALEXPRESSIONS
+4

:

ISSIM ALL Configuration - IOS Simulator Platform Project- > Options,

    {$IFDEF ISSIM}
s := 'iOS Simulator';
    {$ELSE}
s := 'iOS device';
    {$ENDIF}

enter image description here

-1

Source: https://habr.com/ru/post/1541568/


All Articles