0

I've migrated my project from iOS 7 to iOS 8 keeping iOS 7 support. Since i've redone all the graphics i've thrown away the old storyboard and created a new one using the new universal storyboard and size classes.

Everything works fine for iOS 8 iPhone/iPad and iOS 7 iPhone but on iOS 7 iPad i'll keep getting the following error:

[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?

the app didn't even reach application:didFinishLaunchingWithOptions and i know the problem is the storyboard, because if i create an empty one the app start fine.

What am i missing? Do i need an ad hoc storyboard only for ipad to support iOS 7? or there is another way?

EDIT:

during some test, i've found that the method that throw the exception is:

[storybord instantiateInitialViewController];

or

[storyboard instantiateViewControllerWithIdentifier:@"id"];

i've launched the application with an empty storyboard and loaded my storyboard in the app delegate. The storyboard is not nil, but the app crash on that method. Loading a view controller that is not the initial one doesn't change the result.

whtman
  • 254
  • 3
  • 11
  • Have you deleted the original app from the iOS7 ipad/simulator and then tried running? I have found that sometimes old versions can get in the way of new ones, especially on the simulator and if you have made big changes. Also shutdown the simulator and restart if that is what you are using. – Rory McKinnel Mar 02 '15 at 13:41
  • yes i've cleaned the emulator from the old version and restarted it, but nothing appened – whtman Mar 02 '15 at 14:38
  • This person seems to have the opposite issue from you:http://stackoverflow.com/questions/28565010/app-crashes-at-run-befor-reaching-my-code-xcode6-1-universal-app-objectiv-c-nske . However not sure I agree with their answer as I have an app using iOS7 and 8 with size constraints and it works fine on iphone and ipad on both iOS versions. – Rory McKinnel Mar 02 '15 at 15:14
  • I see the question but i would like to have a unique storyboard. I've checked another project (ios 7/8, unique storyboard ) and that work fine, so there must be some error in my storyboard, i'll try to find it out. – whtman Mar 02 '15 at 15:28
  • Only other though I have is did you code your iPad version in the Regular/Regular storyboard view or are you using the Any/Any view. If not using Any/Any it could be that for iPad iOS7 it has no UI to load due to limited support for size classes in iOS7 iPad. – Rory McKinnel Mar 02 '15 at 15:30
  • I've use the regular\regular storyboard for iPad, but maybe i missed a view controller i'll check it out. – whtman Mar 03 '15 at 10:43

2 Answers2

1

I was having this same issue and narrowed it down to a Collection View that I had installed for my compact/any size class, but uninstalled for my any/any size class. It seems that iOS 7 has trouble with prototype cells when the collection view they belong to is uninstalled in the active size class. Running on iOS 8 works fine so if you're only supporting iOS 8 and above, you won't run into this issue.

Prototype cell(s) active (Doesn't work): Uninstalled Collection View with Prototype Cell

Prototype cell(s) removed (Works): Uninstalled Collection View without Prototype Cell

To solve this, I'm going to create a xib that will be programmatically loaded for iPad and keep the storyboard for use on iPhone. Since the view in question doesn't need a Collection View on iPad, the xib should be pretty simple, but it still sucks to have to do this from a maintenance standpoint.

tylermilner
  • 434
  • 4
  • 7
  • Hi Cubd, i think your solution is the correct one, my case was the same as yours but since i need the collection view on both iPad and iPhone i simply enabled it on iPad and everything worked. I'll mark your answer as correct since is more complete. – whtman Mar 19 '15 at 14:05
0

I've been finally able to resolve it, i found out that an element with an outlet in a viewController had only the iphone size class (i forgot to add it to the regular\regular size class) this caused the error.

Adding it to the regular\regular size class solved the problem

whtman
  • 254
  • 3
  • 11