Is there a method though it wants to开发者_高级运维 test when the application is updated?
I am embarrassed because there is a bug that occurs only when the application is updated, and it doesn't investigate.
If you are asking if you want to find when the application is updated through app store, I am not aware of such a method.
A hackie approach to do this is to save the current app version to NSUserDefaults, then check if the NSUserDefaults app version is equal to the current app version.
For example:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *currentAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
if ([defaults objectForKey:@"savedAppVersionKey"] != nil) {
//key exists
NSString *savedAppVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedAppVersionKey"];
if ([currentAppVersion isEqualToString:savedAppVersion]) {
//still running the same app version
}
else {
//the app version changed from the last launch
}
}
else {
//first run, set the key & synchronize
[[NSUserDefaults standardUserDefaults] setObject:currentAppVersion forKey:@"savedAppVersionKey"];
[[NSUserDefaults standardUserDefaults] synchronize]
}
}
I haven't tested the code, but it should work.
Thanks,
-David
Instead of running your app from Xcode, you can drag the app to your iTunes. After this, the app will be installed by the iTunes when you sync (you will need to have the provisioning profile installed, but if you can run thru Xcode, you already have it). You can then drag the newer version of the app to the iTunes and update it by doing a sync (make sure you changed the app version, or iTunes won't update the app).
I don't know if it will be exacly the same process that occur in the update, but I believe it's the best we can do to test it.
this might help as it is apple recommended way to test updates in your app http://developer.apple.com/library/ios/#technotes/tn2285/_index.html#//apple_ref/doc/uid/DTS40011323
The best approach would be to create an ipa file with your development provisioning profile of the old version of the app. Some have mentioned that you can sync this file with iTunes. Actually that's not the easiest way; use the X-Code organizer instead to drag the ipa file to your device under "Devices" > [Your device name] > "Applications". This will install the old version of your application instantaneously.
At this point, it may be important to start your app at this point and recreate whatever situation you are trying to recreate exactly. (Note: the X-Code organizer allows you to transfer files in/out of your Sandbox using the "Download" and "Upload" tabs at the bottom of the Organizer on the Devices tab, so it may not be necessary to perform all state creation logic manually.)
Once the old app is installed and in the state you are trying to recreate, you can launch the new app on top of the old one, or deploy a new ipa from Test-Flight/X-Code Organizer.
Particularly when launching from the debugger, it seems as if the bundle/sandbox location does not/may not change; when updating from Test-Flight it does. It's not clear to me at the present time whether that location can change on an actual app update from iTunes, but it's definitely something you'd want to account for in testing.
精彩评论