【ipa】check Provision

手動檢查

  1. 將輸出的 .ipa,改為 .zip,解壓縮。
  2. 開啟 Terminal 並移動到該 解壓縮後的 Payload 中,會看到 embedded.mobileprovision
  3. security cms -D -i embedded.mobileprovision
  4. 解析結構就可發現不同點

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
NSData *provisioningProfile = nil;
NSData *raw = [NSData dataWithContentsOfURL:[NSBundle.mainBundle URLForResource:@"embedded" withExtension:@"mobileprovision"]];
char *start = memmem(raw.bytes,
                     raw.length,
                     "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0",
                     47);
if (start) {
    char *end = memmem(start,
                       (uintptr_t)start - raw.length,
                       "</plist>",
                       8);
    if (end) {
        provisioningProfile = [NSData dataWithBytes:start length:8 + end - start];
    }
}

if (provisioningProfile) {
    NSDictionary* plist = [NSPropertyListSerialization propertyListWithData:provisioningProfile
                                                                    options:NSPropertyListImmutable
                                                                     format:0
                                                                      error:0];
    NSLog(@"\n\n\nTeam name: %@", plist[@"TeamName"]);

    if ([plist[@"ProvisionsAllDevices"] boolValue]) {
        NSLog(@"Enterprise");
    } else if ([plist[@"ProvisionedDevices"] count] > 0) {
        if ([plist[@"Entitlements"][@"get-task-allow"] boolValue]) {
            NSLog(@"Development");
        } else {
            NSLog(@"Ad Hoc");
        }
    } else {
        NSLog(@"App Store");
    }
}

分析結構

Dev

若是 Dev build app,會看到

1
2
<key>get-task-allow</key>
<true/>

Ad-Hoc

若是 Ad-Hoc

1
2
<key>get-task-allow</key>
<false/>

1
2
3
4
5
6
<key>ProvisionedDevices</key>
<array>
    <string>abcdef01234567890abcdef01234567890abacde</string>
    <string>1abcdef01234567890abcdef01234567890abacd</string>
    <string>2abcdef01234567890abcdef01234567890abacd</string>
</array>