Simulator Detection
Protection Module: SimulatorDetection
Available For
| Platform | Version | Status |
|---|---|---|
| iOS | 12.0+ | ✓ Full Support |
| iPadOS | 12.0+ | ✓ Full Support |
| tvOS | 12.0+ | ✓ Supported |
How It Works
The Simulator Detection module identifies whether your application is running in an iOS simulator or on a physical device. It uses multiple reliable detection techniques that are difficult to bypass:
Detection Techniques
- TARGET_OS_SIMULATOR Compile-Time Flag: Checks the compile-time flag that differentiates simulator builds from device builds at compilation.
- Architecture Detection: Analyzes CPU architecture; simulator environments use x86_64 or i386 architectures, while devices use ARM64 or similar ARM architectures.
- SIMULATOR_ROOT Environment Variable: Checks for the presence of the
SIMULATOR_ROOTenvironment variable, which is set only in simulator contexts. - Device Model Name: Verifies the device model string; simulator returns "Simulator" in the model name.
Detection Confidence: 1.0 (100% - extremely reliable detection)
Default Interval: 60 seconds
Caching: Cached permanently (simulator status doesn't change at runtime)
JSON Configuration
JSON
{
"protections": [
{
"type": "SimulatorDetection",
"action": "close",
"intervalMs": 60000
}
]
}{
"protections": [
{
"type": "SimulatorDetection",
"action": "close",
"intervalMs": 60000
}
]
}Code-Based Configuration
Swift
Swift
import ByteHideMonitor
BHMMonitor.configure { config in
config.enableProtection(.simulatorDetection, action: .close, intervalMs: 60000)
}import ByteHideMonitor
BHMMonitor.configure { config in
config.enableProtection(.simulatorDetection, action: .close, intervalMs: 60000)
}Objective-C
OBJC
#import <ByteHideMonitor/ByteHideMonitor.h>
[BHMMonitor configure:^(BHMMonitorConfiguration *config) {
[config enableProtection:BHMProtectionModuleTypeSimulatorDetection
action:BHMActionTypeClose
intervalMs:60000];
}];#import <ByteHideMonitor/ByteHideMonitor.h>
[BHMMonitor configure:^(BHMMonitorConfiguration *config) {
[config enableProtection:BHMProtectionModuleTypeSimulatorDetection
action:BHMActionTypeClose
intervalMs:60000];
}];Available Actions
| Action | Behavior | Recommended For |
|---|---|---|
| Close | Terminate application immediately | Production apps with critical IP |
| Log | Record incident and continue | Development, analytics |
| Erase | Securely delete data then terminate | Financial, healthcare apps |
| Custom | Execute custom handler | Enterprise integrations |
| None | Detect only, no action | Testing configurations |
See Actions for detailed action documentation.
When to Use
- Production Releases: Prevent distribution and testing on simulators
- Testing Environments: Identify when running in development vs. production
- License Enforcement: Allow only physical device usage for paid apps
- Sensitive Data Apps: Restrict simulator access to protect real user data
- Beta Testing: Control which devices can run beta versions
- Development: Use
Logaction during development to track simulator usage - Analytics: Monitor simulator vs. device distribution
Code Examples
Swift Basic Configuration
Swift
import ByteHideMonitor
// In your AppDelegate or app initialization
BHMMonitor.configure { config in
config.enableProtection(.simulatorDetection, action: .close, intervalMs: 60000)
}import ByteHideMonitor
// In your AppDelegate or app initialization
BHMMonitor.configure { config in
config.enableProtection(.simulatorDetection, action: .close, intervalMs: 60000)
}Swift with Custom Action
Swift
import ByteHideMonitor
BHMMonitor.configure { config in
// Register custom handler for simulator detection
config.registerCustomAction("simulator-handler") { context in
let threatType = context.threatType
let description = context.threatDescription
let metadata = context.metadata
// Log simulator usage
Analytics.log(event: "simulator_detected", parameters: [
"threat_type": threatType,
"description": description,
"timestamp": ISO8601DateFormatter().string(from: Date())
])
// Optionally enable development-only features
DevelopmentMode.enable()
// Notify backend of development environment usage
APIClient.reportEnvironmentUsage(
environment: "simulator",
appVersion: Bundle.main.appVersion
)
}
config.enableProtection(.simulatorDetection, customAction: "simulator-handler", intervalMs: 60000)
}import ByteHideMonitor
BHMMonitor.configure { config in
// Register custom handler for simulator detection
config.registerCustomAction("simulator-handler") { context in
let threatType = context.threatType
let description = context.threatDescription
let metadata = context.metadata
// Log simulator usage
Analytics.log(event: "simulator_detected", parameters: [
"threat_type": threatType,
"description": description,
"timestamp": ISO8601DateFormatter().string(from: Date())
])
// Optionally enable development-only features
DevelopmentMode.enable()
// Notify backend of development environment usage
APIClient.reportEnvironmentUsage(
environment: "simulator",
appVersion: Bundle.main.appVersion
)
}
config.enableProtection(.simulatorDetection, customAction: "simulator-handler", intervalMs: 60000)
}Objective-C Basic Configuration
OBJC
#import <ByteHideMonitor/ByteHideMonitor.h>
[BHMMonitor configure:^(BHMMonitorConfiguration *config) {
[config enableProtection:BHMProtectionModuleTypeSimulatorDetection
action:BHMActionTypeClose
intervalMs:60000];
}];#import <ByteHideMonitor/ByteHideMonitor.h>
[BHMMonitor configure:^(BHMMonitorConfiguration *config) {
[config enableProtection:BHMProtectionModuleTypeSimulatorDetection
action:BHMActionTypeClose
intervalMs:60000];
}];Objective-C with Custom Action
OBJC
#import <ByteHideMonitor/ByteHideMonitor.h>
[BHMMonitor configure:^(BHMMonitorConfiguration *config) {
[config registerCustomAction:@"simulator-handler" handler:^(BHMThreatContext *context) {
NSString *threatType = context.threatType;
NSString *description = context.threatDescription;
NSDictionary *metadata = context.metadata;
// Log simulator usage
[Analytics logEvent:@"simulator_detected"
parameters:@{
@"threat_type": threatType,
@"description": description,
@"timestamp": [NSDate date]
}];
// Enable development features
[DevelopmentMode enable];
// Report to backend
[[APIClient sharedClient] reportEnvironmentUsage:@"simulator"
appVersion:[NSBundle mainBundle].appVersion];
}];
[config enableProtection:BHMProtectionModuleTypeSimulatorDetection
customAction:@"simulator-handler"
intervalMs:60000];
}];#import <ByteHideMonitor/ByteHideMonitor.h>
[BHMMonitor configure:^(BHMMonitorConfiguration *config) {
[config registerCustomAction:@"simulator-handler" handler:^(BHMThreatContext *context) {
NSString *threatType = context.threatType;
NSString *description = context.threatDescription;
NSDictionary *metadata = context.metadata;
// Log simulator usage
[Analytics logEvent:@"simulator_detected"
parameters:@{
@"threat_type": threatType,
@"description": description,
@"timestamp": [NSDate date]
}];
// Enable development features
[DevelopmentMode enable];
// Report to backend
[[APIClient sharedClient] reportEnvironmentUsage:@"simulator"
appVersion:[NSBundle mainBundle].appVersion];
}];
[config enableProtection:BHMProtectionModuleTypeSimulatorDetection
customAction:@"simulator-handler"
intervalMs:60000];
}];Platform Compatibility
| Feature | iOS 12-13 | iOS 14-15 | iOS 16+ |
|---|---|---|---|
| Compile-Time Flag Check | ✓ | ✓ | ✓ |
| Architecture Detection | ✓ | ✓ | ✓ |
| Environment Variable Check | ✓ | ✓ | ✓ |
| Device Model Detection | ✓ | ✓ | ✓ |
| Permanent Caching | ✓ | ✓ | ✓ |
| Reliable on All Simulators | ✓ | ✓ | ✓ |
Performance Impact
- CPU Usage: <0.1% (single check at startup, then cached)
- Memory Overhead: <100 KB (cached result)
- Battery Impact: Negligible (permanent cache)
- First Detection: <10ms
- Runtime Overhead: Minimal (cached permanently)
Threat Detection Details
JSON
{
"threat": {
"moduleType": "SimulatorDetection",
"threatType": "SimulatorDetected",
"threatDescription": "Application running in iOS simulator, not on physical device",
"detectionResult": {
"isThreat": true,
"category": "Environment",
"threatDescription": "Simulator environment detected",
"confidence": 1.0,
"evidence": {
"target_os_simulator": true,
"architecture": "x86_64",
"device_model": "iPhone 14 Pro Simulator",
"simulator_root": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Simulator/RuntimeRoot",
"environment_variable": "SIMULATOR_ROOT"
},
"timestamp": "2026-03-03T10:30:45.123Z"
},
"metadata": {
"cache_status": "permanent",
"check_duration_ms": 3,
"interval_ms": 60000,
"cached_at_startup": true
}
}
}{
"threat": {
"moduleType": "SimulatorDetection",
"threatType": "SimulatorDetected",
"threatDescription": "Application running in iOS simulator, not on physical device",
"detectionResult": {
"isThreat": true,
"category": "Environment",
"threatDescription": "Simulator environment detected",
"confidence": 1.0,
"evidence": {
"target_os_simulator": true,
"architecture": "x86_64",
"device_model": "iPhone 14 Pro Simulator",
"simulator_root": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Simulator/RuntimeRoot",
"environment_variable": "SIMULATOR_ROOT"
},
"timestamp": "2026-03-03T10:30:45.123Z"
},
"metadata": {
"cache_status": "permanent",
"check_duration_ms": 3,
"interval_ms": 60000,
"cached_at_startup": true
}
}
}Related Protections
- Debugger Detection - Detect attached debuggers
- Jailbreak Detection - Detect jailbroken devices
- Tampering Detection - Verify app integrity
- Process Injection - Detect code injection
Next Steps
- Actions Documentation - Learn about available response actions
- Custom Actions - Build custom threat handlers
- Configuration API - Full API reference
- Getting Started - Monitor setup guide