I have a code like this in my app:
NSString* version = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
In most cases it works, and returns the Bundle version
, but sometimes (let's say in 2% of cases) it returns nil
.
The code is called within the function [AppDelegate application:didFinishLaunchingWithOptions:]
, in Main thread, an app is in foreground.
I could imagine this being an Apple's bug with some file reading error, but the percentage is quite high as for a rare Apple bug.
Also I know a one could mess with versions/bundles/Info.plist
- but the percentage is too small for such case.
So, the first question: what can be the reason of [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]
returning nil
in this case?
The second question: do you know if these hypotheses make sense / are easy to check:
- The user launches an app the first time after update, and
[NSBundle mainBundle]
becomes fully configured afterapplication:didFinishLaunchingWithOptions
? - The app is in the process of an auto-update (from AppStore), the user opens it, and the system is currently writing a new data to
Info.plist
. - Some background thread in my app is also reading the
[NSBundle mainBundle]
, the system uses some weird lock, so the read from a Main thread fails.
UPD: I've seen this question, but it's not related.