iOS Simulator Does Not Delete User Defaults After App Is Deleted in Xcode 6 beta 6 iOS 8 sim

Originator:designatednerd
Number:rdar://18084423 Date Originated:8/20/2014
Status:Open Resolved:
Product:Xcode Product Version:6, Beta 6
Classification:Serious Bug Reproducible:Always
 
Summary:
When an iOS application is deleted from the Xcode 6 beta 6 iOS 8 simulator, its NSUserDefaults are not deleted along with the app. 

This can be resolved by: 1) using a device rather than a simulator or 2) resetting content and settings on the simulator.

Steps to Reproduce:
1. Open attached sample project. 
2. Build and run application in simulator. Note that screen says "NO", indicating the application has not yet run. 
3. Build and run application in simulator again. Note that screen says "YES", indicating the application has run. 
4. Uninstall application from simulator, which in theory should nuke the user defaults. 
5. Build and run application in simulator again. Note that screen says "YES", indicating that the boolean value for the given key is still set, which it should not be if the user defaults were nuked. 

Expected Results:
1. Open attached sample project. 
2. Build and run application on device. Note that screen says "NO", indicating the application has not yet run. 
3. Build and run application on device again. Note that screen says "YES", indicating the application has run. 
4. Uninstall application from device, which in theory should nuke the user defaults. 
5. Build and run application on device again. Note that screen says "NO", indicating that the user defaults were appropriately nuked. 

Actual Results:
(see steps to repro)

Version:
Xcode 6 beta 6, iOS 8 SDK beta 5, OS X 10.9.4

Notes:
Though the sample app is in Swift, this happens regardless of whether the language used to access the NSUserDefaults is Swift or Obj-C. 

Configuration:
Happens every time on the sim using my configuration. 

Attachments:
(single-VC app with the following code in the ViewController:

    override func viewDidLoad() {
        super.viewDidLoad()

        let key = "hasLaunchedBefore"
        let hasLaunched = NSUserDefaults.standardUserDefaults().boolForKey(key)
        testLabel?.text = hasLaunched ? "YES" : "NO"
        
        NSUserDefaults.standardUserDefaults().setBool(true, forKey: key);
        NSUserDefaults.standardUserDefaults().synchronize()
    }


On device, it will display NO every time you uninstall and rerun the app. On simulator, it will display NO the first time you ever run the app, and then YES every time thereafter unless you reset content and settings.

)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!