Why my application will not start in Xcode 8 beta (8S128d)

This is a problem that will affect many applications and can be found in Xcode 8 beta (8S128d). This is the first beta, although it is not marked as beta-1.

The problem is with NSUserDefaults; he does not work. Here, the code may be placed in application:didFinishLaunchingWithOptions:

 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setValue:@"hello world" forKey:@"TEST"]; [defaults synchronize]; NSString * oops = [[NSUserDefaults standardUserDefaults] valueForKey:@"TEST"]; NSLog(@"default = %@", oops); 

In Xcode 7 and earlier, this code works as expected: the oops value is "hello world."

In Xcode 8, the value of oops is nil .

This is pretty big!

+3
xcode ios10 xcode8
Jun 15 '16 at 0:19
source share
1 answer

Found answer: https://forums.developer.apple.com/message/143155#143155

If you used Xcode 7 or earlier, you need to restart your Mac before running the iOS 10 simulator.

From the release notes:

WWDC Seed: Running multiple iOS simulators may cause NSUserDefaults to not work.

Running the iOS 8 or 9 simulator and then the iOS 10 simulator will cause NSUserDefaults to stop working in the simulator. This can be circumvented by restarting the Mac host.

+8
Jun 15 '16 at 0:31
source share



All Articles