A lightweight Swift extension for UIDevice that checks for common jailbreak indicators.
Legacy reference. Modern iOS integrity checks rely on App Attest (and DeviceCheck), so this heuristic approach is far less relevant today.
- URL scheme checks, file presence scans, and a write test.
- Configurable jailbreak scheme via
X0R_KEYin your Info.plist/XCConfig. - Simple
UIDeviceAPI:x04(jailbroken) andx102(simulator).
Use Swift Package Manager (Xcode: File → Add Packages...) with:
https://github.com/deya-eldeen/JailbreakDetector.git
Or add Sources/X04Checker/X04.swift to your project.
if UIDevice.current.x04 {
// Device appears jailbroken—take action (disable features, alert user, etc.)
}SwiftUI sample:
import SwiftUI
import X04Checker
struct ContentView: View {
@State private var monkey = false
@State private var showAlert = false
var body: some View {
VStack(spacing: 20) {
Text("Monkey status:")
.font(.headline)
Text(monkey ? "🐒 Monkey!" : "✅ Clean")
.font(.title)
.foregroundColor(monkey ? .red : .green)
}
.padding()
.onAppear {
monkey = UIDevice.current.x04
showAlert = monkey
}
.alert("Warning", isPresented: $showAlert) {
Button("OK", role: .cancel) { }
} message: {
Text("Your device appears to have a monkey. Certain features may be disabled.")
}
}
}A sample iOS app lives at Example/ExampleApp.xcodeproj and uses the package directly.
| Clean | Affected |
|---|---|
![]() |
![]() |
JailbreakDetector runs three checks:
- URL scheme:
UIApplication.shared.canOpenURL(URL(string: "<scheme>://")). - File checks: scans a list of suspicious paths.
- Write test: attempts to write outside the sandbox (e.g.
/private/monkey_write_test).
Simulator always returns false for x04 to avoid development false positives.
- Add paths in
JailbreakDetector.suspiciousPaths(Sources/X04Checker/X04.swift). - Change the default scheme (
"cydia") or injectX0R_KEYvia XCConfig. - Add logging/metrics around each check if needed.
This package targets iOS and uses UIKit, so build it with Xcode or xcodebuild for an iOS destination.
Xcode:
- Open
Package.swift - Select an iOS Simulator destination
- Build (⌘B)
CLI:
xcodebuild -scheme X04Checker -destination 'platform=iOS Simulator,name=iPhone 14' -sdk iphonesimulator buildRun tests on an iOS Simulator (UIKit is not available on macOS targets).
Xcode:
- Open
Package.swift - Select an iOS Simulator destination
- Test (⌘U)
CLI:
xcodebuild -scheme X04Checker -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.6' -sdk iphonesimulator testGenerate an obfuscated copy while keeping a readable source for maintenance:
python3 scripts/obfuscate.py Sources/X04Checker/X04.swift --out dist/X04.swiftNotes:
- Public/open identifiers are preserved automatically.
- Add extra preserved identifiers with
--preserve name1,name2. - This is a best-effort token replacer and does not change string contents or comments (interpolation expressions are updated).
- Replace the Swift file you embed in your app with the obfuscated output.
- Original concept by Vineet Choudhary.
- Article: Best Way to Check if Your iOS App Is Running on a Jailbroken Phone
Security disclaimer: No jailbreak detection is foolproof. Always combine detection with server-side safeguards and integrity checks.

