Reputation: 1339
I'm currently implementing some simple Unit Tests for my app.
One simple Testcase is instantiating an AVAudioPlayer with a predefined file. This test works perfectly on the device. However if I use the Simulator to test the App, apparently an other folder structure is used, because the Test Resources are not copied to the tmp folder.
This is the path used on the phone:
soundPath = [[NSString alloc] initWithFormat:@"%@Tests.octest/%@", NSTemporaryDirectory(), fileName];
I have implemented a simple check if I'm on the simulator:
if (TARGET_IPHONE_SIMULATOR)
soundPath = @"";
else
...
So which path should I use if I'm on the Simulator? (I know I could use the hardcoded Path to the resource, but this project will run on different Computers, so I can't put it in there..)
Thanks for your help...
Upvotes: 0
Views: 230
Reputation: 148
You are using the wrong methods.
You can get the bundle Path using:
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
soundPath = [bundle bundlePath];
This will return the whole path (including Tests.octest)
HTH Mattias
Upvotes: 1