Search code examples
iosios8ios-simulatorxctestios-permissions

Manipulate app permissions on iOS 8 simulator


Same question as this one, but for iOS 8.

While running xctests, how can I make sure permissions are granted/denied programmatically?

Is the same TCC.db used? If so, as there are no $HOME/Library/Application Support/iPhone Simulator/8.x directories, where has it moved to?


Solution

  • Thanks to username tbd, the TCC.db is still in use, but is now located at

    $HOME/Library/Developer/CoreSimulator/Devices/$DEVICEID/data/Library/TCC/

    Schema of the "access" table is the same.

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *dbPath = [paths firstObject];
    
    for (int ii = 0; ii < 5; ii++) {
        dbPath = [dbPath stringByDeletingLastPathComponent];
    }
    
    dbPath = [[[dbPath stringByAppendingPathComponent:@"Library"]
               stringByAppendingPathComponent:@"TCC"]
              stringByAppendingPathComponent:@"TCC.db"];
    

    Note though that TCC is only for Accounts access (contacts, mail, etc.) and not all permissions.