Disabling Autolayout in Xcode

Every time you add some user interface to your iOS app, Xcode will enable by default the Autolayout flag, which is a PITA because it’s not supported for 5.1 targets.

I found a StackOverflow answer that solves this problem, but it needs to be done every time Xcode is updated.

Some scripting may help to automate this:

In your favorite terminal (you’re using iTerm2, right?)


cd "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/User Interface/"

find . -name "*.xib" -exec perl -i -pe 's#<bool key="IBDocument.UseAutolayout">YES#<bool key="IBDocument.UseAutolayout">NO#' "{}" \;

Voila. You’re done.

Bonus: Duplicate the « User Interface » folder before applying the transformation and rename it « User Interface_on ».

Rename the modified folder to « User Interface_off » and they’ll both appear in Xcode when you create a new interface file.

Screen Shot 2013-03-05 at 11.41.35