Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jailbreak detector
extension UIDevice {
private class JailbreakDetector {
static var current: JailbreakDetector = JailbreakDetector()
lazy var containsSuspiciousFiles: Bool = {
return (["/Applications/",
"/private/var/lib/apt/"].first(where: {
FileManager.default.fileExists(atPath: $0)
}) != nil)
/// Whether user is using jailbroken device
var isJailbroken: Bool {
guard self == UIDevice.current else {
return false
// Check that we are not using the simulator
#if arch(i386) || arch(x86_64)
return false
return JailbreakDetector.current.containsSuspiciousFiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment