From 8bb7a7c97e41e3e8c06a267adfccfd28aee08231 Mon Sep 17 00:00:00 2001 From: Levi Buzolic Date: Wed, 27 Oct 2021 17:14:02 +1100 Subject: [PATCH] iOS simulator mock location check --- JailMonkey/JailMonkey.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/JailMonkey/JailMonkey.m b/JailMonkey/JailMonkey.m index c739f15..9891688 100644 --- a/JailMonkey/JailMonkey.m +++ b/JailMonkey/JailMonkey.m @@ -298,10 +298,17 @@ - (BOOL)isJailBroken{ return [self checkPaths] || [self checkSchemes] || [self canViolateSandbox] || [self canFork] || [self checkSymlinks] || [self checkDylibs]; } +- (BOOL)canMockLocation{ + #if TARGET_OS_SIMULATOR + return YES; + #endif + + return [self isJailBroken]; +} -(NSString *)jailBrokenMessage{ NSString *errorMessage = @""; - + if([self isJailBroken]) { if ([self checkPaths]) { @@ -370,10 +377,10 @@ - (NSString *)checkSymlinksMessage - (NSString *)checkDylibsMessage { NSString *imagePath = @""; - + for (int i=0; i < _dyld_image_count(); i++) { imagePath = [NSString stringWithUTF8String:_dyld_get_image_name(i)]; - + for (NSString *dylibPath in [self dylibsToCheck]) { if([imagePath localizedCaseInsensitiveContainsString:dylibPath]) { imagePath = [NSString stringWithFormat:@"%@,%@", imagePath, dylibPath]; @@ -387,7 +394,7 @@ - (NSDictionary *)constantsToExport { return @{ JMisJailBronkenKey: @(self.isJailBroken), - JMCanMockLocationKey: @(self.isJailBroken), + JMCanMockLocationKey: @(self.canMockLocation), JMJailBrokenMessageKey : [self jailBrokenMessage] }; }