Reputation: 17359
I'd like to ensure with unit tests that important values inside my main MyApp-Info.plist
are there and correct. Is there a way to load that plist from within my unit test bundle?
Upvotes: 3
Views: 2471
Reputation: 3028
You can include your Info.plist in the Unit test bundle as a resource as well. That way, there's no dependency on the host application. However, finding and loading the resource requires just a tiny bit of trickery that seems to always trip me up.
See this question for examples on how to do that from ObjC and Swift.
Upvotes: 1
Reputation: 8638
It depends on if you have set a host application for your test target. If there is no host application, then the file is not copied with the test.
If there is a host application you can get its plist contents with:
Swift:
Bundle.main.infoDictionary
Objective-C:
[[NSBundle mainBundle] infoDictionary]
Upvotes: 5