Skip to content

Commit

Permalink
iOS simulator mock location check
Browse files Browse the repository at this point in the history
  • Loading branch information
levibuzolic committed Oct 27, 2021
1 parent 13691af commit 8bb7a7c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions JailMonkey/JailMonkey.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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];
Expand All @@ -387,7 +394,7 @@ - (NSDictionary *)constantsToExport
{
return @{
JMisJailBronkenKey: @(self.isJailBroken),
JMCanMockLocationKey: @(self.isJailBroken),
JMCanMockLocationKey: @(self.canMockLocation),
JMJailBrokenMessageKey : [self jailBrokenMessage]
};
}
Expand Down

0 comments on commit 8bb7a7c

Please sign in to comment.