Unit Testing Target not recognizing static csv file
-
12-12-2019 - |
Question
I am running Xcode 4.5 and I have added a new unit testing target to an existing project.
I added a csv file to the Copy Bundle Resources
section of the target, but the target is not recognizing the file as part of the bundle. When I run the following in LLDB, I get nil result:
po [NSBundle mainBundle]
(id) $2 = 0x01937180 NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/Developer/usr/bin> (loaded)
po [[NSBundle mainBundle] pathForResource:@"myFile" ofType:@"csv"]
(id) $3 = 0x00000000 <nil>
is there an additional step to get the target to recognize the file?
Solution
This one is a read the docs type of answer.
It turns out that calling [NSBundle mainBundle]
does not load the bundle that holds that targets files. Instead I need to get the other bundles identifier and use that bundle. After which everything worked as expected.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow