Skip to content

Instantly share code, notes, and snippets.

@gcasa
Created June 27, 2020 15:43
Show Gist options
  • Save gcasa/a09576e0e4ac4cbe232d56ea865dad01 to your computer and use it in GitHub Desktop.
Save gcasa/a09576e0e4ac4cbe232d56ea865dad01 to your computer and use it in GitHub Desktop.
The purpose of this script is to allow users of current versions of Xcode to easily turn off autolayout. (for builds for older versions of macOS eg 10.6)
#!/bin/sh
PROJECT_DIR=$1
XIB_NAME=${3:-MainMenu.xib}
LANG_NAME=${2:-Base}
FULL_XIB_NAME=${PROJECT_DIR}/${LANG_NAME}.lproj/${XIB_NAME}
echo "Replacing usesAutolayout and translatesAutoresizingMaskIntoConstraints"
echo "INFO: For some reason recent versions of Xcode do not allow this to be turned off..."
echo " This script will need to be run after you visit the xib again in Xcode as it will"
echo " automatically regenerate the xib and turn autolayout back on automatically."
echo " "
cat ${FULL_XIB_NAME} | sed 's/useAutolayout="YES"/useAutolayout="NO"/g' | sed 's/translatesAutoresizingMaskIntoConstraints="YES"/translatesAutoresizingMaskIntoConstraints="YES"/g' > ${FULL_XIB_NAME}.new
mv ${FULL_XIB_NAME} ${FULL_XIB_NAME}.old
echo "Saved old xib as ${XIB_NAME}.old"
mv ${FULL_XIB_NAME}.new ${FULL_XIB_NAME}
echo "Replaced original xib with modified one."
echo "Done."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment