Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active February 7, 2025 15:27

Revisions

  1. steipete revised this gist Nov 26, 2013. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions DevelopmentEnviromentDetector.m
    Original file line number Diff line number Diff line change
    @@ -2,20 +2,22 @@ static BOOL PSPDFIsDevelopmentBuild(void) {
    #if TARGET_IPHONE_SIMULATOR
    return YES;
    #else
    @autoreleasepool {
    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 new];
    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:@""];
    return [cleared rangeOfString:@"<key>get-task-allow</key><true/>"].length > 0;
    isDevelopment = [cleared rangeOfString:@"<key>get-task-allow</key><true/>"].length > 0;
    }
    }
    return NO;
    });
    return isDevelopment;
    #endif
    }
  2. steipete renamed this gist Nov 26, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. steipete created this gist Nov 26, 2013.
    21 changes: 21 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    static BOOL PSPDFIsDevelopmentBuild(void) {
    #if TARGET_IPHONE_SIMULATOR
    return YES;
    #else
    @autoreleasepool {
    // 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 new];
    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:@""];
    return [cleared rangeOfString:@"<key>get-task-allow</key><true/>"].length > 0;
    }
    }
    return NO;
    #endif
    }