Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在swift中检查iPhone是否越狱?_Ios_Swift - Fatal编程技术网

Ios 如何在swift中检查iPhone是否越狱?

Ios 如何在swift中检查iPhone是否越狱?,ios,swift,Ios,Swift,我想防止用户伪造GPS坐标,如果iPhone被越狱,可以运行一个应用程序来伪造GPS。因此,为了防止这个问题,我想检查用户是否越狱,如果用户使用越狱iPhone,我将强制关闭应用程序 用Swift怎么做?到目前为止,我在stackoverflow中找不到它这提供了一个非常好的概述 if TARGET_IPHONE_SIMULATOR != 1 { // Check 1 : existence of files that are common for jailbroken devices i

我想防止用户伪造GPS坐标,如果iPhone被越狱,可以运行一个应用程序来伪造GPS。因此,为了防止这个问题,我想检查用户是否越狱,如果用户使用越狱iPhone,我将强制关闭应用程序

用Swift怎么做?到目前为止,我在stackoverflow中找不到它

这提供了一个非常好的概述

if TARGET_IPHONE_SIMULATOR != 1

{

// Check 1 : existence of files that are common for jailbroken devices

if FileManager.default.fileExists(atPath: “/Applications/Cydia.app”)

|| FileManager.default.fileExists(atPath: “/Library/MobileSubstrate/MobileSubstrate.dylib”)

|| FileManager.default.fileExists(atPath: “/bin/bash”)

|| FileManager.default.fileExists(atPath: “/usr/sbin/sshd”)

|| FileManager.default.fileExists(atPath: “/etc/apt”)

|| FileManager.default.fileExists(atPath: “/private/var/lib/apt/”)

|| UIApplication.shared.canOpenURL(URL(string:”cydia://package/com.example.package”)!)

{

return true

}

// Check 2 : Reading and writing in system directories (sandbox violation)

let stringToWrite = “Jailbreak Test”

do

{

try stringToWrite.write(toFile:”/private/JailbreakTest.txt”, atomically:true, encoding:String.Encoding.utf8)

//Device is jailbroken

return true

}catch

{

return false

}

}else

{

return false

}

你检查了吗?看一个问题,因为我发现很有趣,“越狱检测系统”硬件不是相关的吗?在我看来,如果它是软导向的,至少可以说是相当不安全的。