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?
Asked
Active
Viewed 1,361 times
1 Answers
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
-
This gets me access to the bundle, not the documents folder (which is what I need) – Stephen Bradley Sep 03 '15 at 15:41
-
@StephenBradley Hi. http://stackoverflow.com/questions/8378712/nshomedirectory-in-iphone-unit-test – Serge Maslyakov Sep 03 '15 at 15:54
-
Tried adding those settings, however now the UI tests fail to launch the app. Specifically on XCUIApplication().launch() I get a sigkill – Stephen Bradley Sep 03 '15 at 19:57