1

Possible Duplicate:
presentViewController: crash on iOS <6 (AutoLayout)
How to use NSLayoutConstraint in iOS 6?
App failing to load

I just started working on an app in the iOS6 SDK and it runs smooth on an iOS 6 device and the iOS 6 Simulator but it doesn't work on iOS 5 or the iOS 5 Simulator. I've set my Deployment Target to: 5.0

This is the error it gives me when it tries to open but it fails...

2013-01-02 14:22:57.075 MyApp[34956:c07] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x14a5052 0xea5d0a 0x144da78 0x144d9e9 0x3327d7 0x3329af 0x3326b7 0x23336d 0xdae2c 0xdb3a9 0xdb5cb 0x3ba73 0x3bce2 0x3bea8 0x42d9a 0x2845 0x139d6 0x148a6 0x23743 0x241f8 0x17aa9 0x138ffa9 0x14791c5 0x13de022 0x13dc90a 0x13dbdb4 0x13dbccb 0x142a7 0x15a9b 0x257d 0x24a5)
terminate called throwing an exception(lldb) 

How can I fix this?

Community
  • 1
  • 1
atomikpanda
  • 1,845
  • 5
  • 33
  • 47
  • http://stackoverflow.com/questions/11252057/nslayoutconstraint-crashes-viewcontroller – Bryan Jan 02 '13 at 19:32
  • 1
    http://stackoverflow.com/questions/12687979/how-to-use-nslayoutconstraint-in-ios-6 – Jack Jan 02 '13 at 19:32
  • Apple makes many changes between major versions. In general, if you want to have code work on a prior version you should primarily target that prior version, and hope that there are not too many incompatibilities going the other way. (But as Brian points out, simply setting deployment target to the prior version is not enough -- you need to consciously avoid facilities only found in the newer version.) – Hot Licks Jan 02 '13 at 19:47

2 Answers2

5

You are using AutoLayout which is a feature that is only available in iOS6. You will need to either limit your iOS version to iOS6 or you will need to disable AutoLayout by going into your .xib's or storyboards and disabling it.

rooster117
  • 5,502
  • 1
  • 21
  • 19
  • ...or remove AutoLayout from the XIBs and inject it only on iOS6 dynamically within the code of your app. – Till Jan 02 '13 at 19:39
  • 1
    Yeah I agree its an option but if you are going to be dynamically adding autolayout code while at the same time performing the same calculations in code or old style of IB layout to support iOS<6 then you might as well just stick with the old for simplicity and move forward when you are only ios6 and above. That's just my opinion though. – rooster117 Jan 02 '13 at 19:45
  • valid point indeed. Still since the iPhone5 is iOS6 and higher only, it sometimes is an option. – Till Jan 02 '13 at 19:46
1

Unfortunately, setting your Deployment Target to a previous OS version does not actually do anything to prevent you from using APIs (or in this case Interface Builder features) that are only available in later versions.

Bryan
  • 8,748
  • 7
  • 41
  • 62