diff --git a/app/AppGroup.m b/app/AppGroup.m index 35a5897b..75c5f674 100644 --- a/app/AppGroup.m +++ b/app/AppGroup.m @@ -7,6 +7,7 @@ #import #include +#include #include struct cs_blob_index { @@ -45,6 +46,19 @@ static NSDictionary *AppEntitlements() { if (header->magic != MH_MAGIC_64) return nil; + // Simulator executables have fake entitlements in the code signature. The real entitlements can be found in an __entitlements section. + size_t entitlements_size; + uint8_t *entitlements_data = getsectiondata(header, "__TEXT", "__entitlements", &entitlements_size); + if (entitlements_data != NULL) { + NSData *data = [NSData dataWithBytesNoCopy:entitlements_data + length:entitlements_size + freeWhenDone:NO]; + return entitlements = [NSPropertyListSerialization propertyListWithData:data + options:NSPropertyListImmutable + format:nil + error:nil]; + } + // Find the LC_CODE_SIGNATURE struct load_command *lc = (void *) (base + sizeof(*header)); struct linkedit_data_command *cs_lc = NULL;