app crashes at run before reaching my code xcode6.

2019-08-04 19:17发布

问题:

App crashes at run under 7.1 simulator or device and runs fine on both with in 8.1

with StackTrace:

appName[10676:607] *** -[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?
appName[10676:607] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '(null)'
*** First throw call stack:
(
    0   CoreFoundation                      0x007a91e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x005258e5 objc_exception_throw + 44
    2   CoreFoundation                      0x007a8fbb +[NSException raise:format:] + 139
    3   UIKit                               0x01064b7b -[UINib instantiateWithOwner:options:] + 951
    4   UIKit                               0x013138bd -[UIStoryboard instantiateViewControllerWithIdentifier:] + 220
    5   UIKit                               0x01313a36 -[UIStoryboard instantiateInitialViewController] + 74
    6   UIKit                               0x00daf6ac -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 79
    7   UIKit                               0x00daf949 -[UIApplication _loadMainInterfaceFile] + 245
    8   UIKit                               0x00dae54e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
    9   UIKit                               0x00dc2f92 -[UIApplication handleEvent:withNewEvent:] + 3517
    10  UIKit                               0x00dc3555 -[UIApplication sendEvent:] + 85
    11  UIKit                               0x00db0250 _UIApplicationHandleEvent + 683
    12  GraphicsServices                    0x02e83f02 _PurpleEventCallback + 776
    13  GraphicsServices                    0x02e83a0d PurpleEventCallback + 46
    14  CoreFoundation                      0x00724ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    15  CoreFoundation                      0x007249db __CFRunLoopDoSource1 + 523
    16  CoreFoundation                      0x0074f68c __CFRunLoopRun + 2156
    17  CoreFoundation                      0x0074e9d3 CFRunLoopRunSpecific + 467
    18  CoreFoundation                      0x0074e7eb CFRunLoopRunInMode + 123
    19  UIKit                               0x00dadd9c -[UIApplication _run] + 840
    20  UIKit                               0x00daff9b UIApplicationMain + 1225
    21  appName                       0x000d3e48 main + 136
    22  libdyld.dylib                       0x02a766d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I'm working with VersionControl as soon as this error occurs. I did step back to previous commit but the error keeps coming. I'm pretty sure it's nothing in my code.

I also tried all solutions from Build universal app for iOS 3.0 using Xcode 4.3.x - NSKeyedUnarchiver Exception

But since it's 2 years old an I use xcode6.1 it doesn't work.

回答1:

The Universial Storyboard introduced in iOS8 works for iPhone and iPad 8 and for iPad 7 but not for iPhone 7 (only if not creating any iPad size layouts)

i solved the problem by using plist-keys Main sroryboard file base name (iPhone) and Main sroryboard file base name (iPad) referencing diffrent Storyboards and the iPhone one referencing the default to avoid any other trouble