• Copy failed

Could Not Instantiate Class Named 'NSLayoutConstraint'

Could Not Instantiate Class Named 'NSLayoutConstraint'

Last week I have started a new project by using xCode 4.5 in combination with storyboards. I really like the storyboards because they are more intuitive to use than the older XIB files.

Today I tested the my first implmentation on different (real) devices, first with the iPhone 4 running with iOS 5.0.1 using English as system language where everything worked perfectly. After that I tested my project on the iPad3 running with iOS 5.1.1 using German as system language and got an exception I have never read before - "Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'". So I used Mr. Google to search for a solution and discovered the solution within a minute. However to remove the exception took a little more time than I had expected...

With xCode 4.5 (precisely iPhone5) Apple has introduced a new functionality called "Autolayout". Everybody who has worked with Storyboards and xCode 4.5 has already discovered this new feature at the right bottom of the Interface Builder.

So, if we try to use this feature for a pre version of iOS6, in my case 5.01. and 5.1.1 than there occurs a runtime exception because "Autolayout" is not available there.


The solution

First select your MainStoryboard.storyboard file in your "Project Navigator". Then select the tab "File Inspector" in your "Utilities" view, scroll down a little bit and uncheck the "Use Autolayout" checkbox.



Last but not least a quite useful information if you are using localization as in my case German and English.

TAKE CARE and uncheck the "Use Autolayout" checkbox for each localization (in my case German and English) of your storyboard!

To find the problem why it has worked on the iPhone4 with iOS 5.0.1 using English as system langugae and neither on the iPad with iOS 5.1.1 using German as system language took my about an hour and one more to write it to my blog ^^



Posted in iOS, Blog

Comments (0)

Leave a comment

You are commenting as guest. Optional login below.