"Code after 'return' will never be executed"
Hi
I am new to this preventing jail broken phone part of ios.
I places the code in class called SecurityUtils.swift, and call the method in appDelegate, didFinishLaunchingWithOptions like this :
if(isJailbroken()){
//jail broken here
}else{
//not jail broken here
}
But I am getting this warning in my securityUtils class, after these lines :
#if arch(i386) || arch(x86_64)
// This is a Simulator not an idevice
return false
#endif
The warning is Code after 'return' will never be executed
So looks like the let fileManager = FileManager.default part will not be executed. How can I fix the #if arch(i386) || arch(x86_64) part?
I have removed the struct from the function of your code, and my function looks like this now :
func isJailbroken() -> Bool {
Anything I should change here?
Thanks
Hey @junweimah ,
Old question but I thought I'd comment anyway.
That warning will only come up if your target is the simulator - as this is what it is checking for as we don't want to run all the checks in the simulator. If you build to device the warning should disappear.
In any case, the modern way to write this would be:
#if targetEnvironment(simulator)
return false
#endif
Hope that helped.
Richie