Skip to content

Commit

Permalink
Merge pull request #114 from GantMan/ios-simulator-mock-location
Browse files Browse the repository at this point in the history
iOS simulator mock location check
  • Loading branch information
levibuzolic authored May 23, 2022
2 parents 399c53a + 8bb7a7c commit 6b9ecf0
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 6b9ecf0

Please sign in to comment.