5

I am writing some UI tests using the new iOS 9 APIs. One thing I am running into, is when you run the tests, its its own target and own "app" on the simulator. This means I am not accessing the sqlite file I have saved in the main apps documents folder. I am having issues figuring out how to actually open this file. Anyone have a solution for this?

Stephen Bradley
  • 373
  • 2
  • 10

1 Answers1

0

Use a [NSBundle bundleForClass:[self class]]

E.g. reading files:

- (NSData *)readFile:(NSString *)name withExtension:(NSString *)extension {
    NSURL *fileURL = [[NSBundle bundleForClass:[self class]] URLForResource:name withExtension:extension];
    return [[NSFileManager defaultManager] contentsAtPath:fileURL.path];
}
Serge Maslyakov
  • 1,410
  • 1
  • 17
  • 23