Loading main XIB makes app crash on iOS 3.0

2019-08-19 03:52发布

thank you for taking some time to read my question. I have this app (In Cydia), which has around 10% of users with iOS 3.0, so I want to support them in my next update .

I tested it with actual devices running, iOS 4.0 and 5.0.1; it worked fine. But on iOS 3.0 it crashes with an exception:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)

apparently when loading the main XIB, here's the backtrace of the exception:

0  0x30016588 in objc_exception_throw ()
1  0x30224026 in +[NSException raise:format:arguments:] ()
2  0x30223fc6 in +[NSException raise:format:] ()
3  0x305564b4 in -[NSKeyedUnarchiver initForReadingWithData:] ()
4  0x3094927c in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] ()
5  0x30949090 in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] ()
6  0x308f131c in -[UIApplication _loadMainNibFile] ()
7  0x308f0f9c in -[UIApplication _runWithURL:sourceBundleID:] ()
8  0x309374b0 in -[UIApplication handleEvent:withNewEvent:] ()
9  0x30936cf0 in -[UIApplication sendEvent:] ()
10 0x3093687c in _UIApplicationHandleEvent ()
11 0x3204696c in PurpleEventCallback ()
12 0x30254a76 in CFRunLoopRunSpecific ()
13 0x3025416a in CFRunLoopRunInMode ()
14 0x308f0354 in -[UIApplication _run] ()
15 0x308eea94 in UIApplicationMain ()
16 0x00003886 in main (argc=1, argv=0x2ffff74c)

I've read and tried this and this. So I have all of my nibs with deployment version set to 3.0 and development to Interface Builder 3.0, still no luck.

2条回答
爷、活的狠高调
2楼-- · 2019-08-19 04:12

I second Emanuel's answer above. After many weeks of pulling my hair out I came up with this solution: Build universal app for iOS 3.0 using Xcode 4.3.x - NSKeyedUnarchiver Exception

查看更多
The star\"
3楼-- · 2019-08-19 04:19

After reading some docs, it became clear that iOS prior 3.2 won't load NIBs from Xcode 4.2, so I ended up building the project with Xcode 3.2 and copied these NIBs to the package created with Xcode 4.2 under the DerivedData directory, the good part is I still can debug the app with Xcode 4.2, the bad part is, this is kinda hacky, but I hadn't choice. Thank you.

查看更多
登录 后发表回答