Jailbreak detector
extension UIDevice { | |
private class JailbreakDetector { | |
static var current: JailbreakDetector = JailbreakDetector() | |
lazy var containsSuspiciousFiles: Bool = { | |
return (["/Applications/Cydia.app", | |
"/Library/MobileSubstrate/MobileSubstrate.dylib", | |
"/bin/bash", | |
"/usr/sbin/sshd", | |
"/etc/apt", | |
"/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 | |
#else | |
return JailbreakDetector.current.containsSuspiciousFiles | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment