Forked from steipete/DevelopmentEnviromentDetector.m
          
        
    
          Created
          November 27, 2013 00:08 
        
      - 
      
- 
        Save haikusw/7668599 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | static BOOL PSPDFIsDevelopmentBuild(void) { | |
| #if TARGET_IPHONE_SIMULATOR | |
| return YES; | |
| #else | |
| static BOOL isDevelopment = NO; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| // There is no provisioning profile in AppStore Apps. | |
| NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]]; | |
| if (data) { | |
| const char *bytes = [data bytes]; | |
| NSMutableString *profile = [[NSMutableString alloc] initWithCapacity:data.length]; | |
| for (NSUInteger i = 0; i < data.length; i++) { | |
| [profile appendFormat:@"%c", bytes[i]]; | |
| } | |
| // Look for debug value, if detected we're a development build. | |
| NSString *cleared = [[profile componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet] componentsJoinedByString:@""]; | |
| isDevelopment = [cleared rangeOfString:@"<key>get-task-allow</key><true/>"].length > 0; | |
| } | |
| }); | |
| return isDevelopment; | |
| #endif | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment