Last active
November 6, 2016 14:14
-
-
Save dlo/1ea59a0de38953668c5a12838942d21f to your computer and use it in GitHub Desktop.
For those of you who’ve run into the Xcode 8 / Swift migrator hanging issue, this script fixes it. It marks all targets in the project as migrated. For any targets that haven’t actually been migrated to Swift 2.3/3, the script outputs a one-liner that you can cut-and-paste to undo individual targets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJ=$1 | |
if [[ -z "$PROJ" ]]; then | |
echo "Please provide a path to an Xcode project file." | |
exit 1 | |
fi | |
ROOT=$(/usr/libexec/PlistBuddy -c "Print rootObject" $PROJ) | |
/usr/libexec/PlistBuddy -c "Add objects:$ROOT:attributes:TargetAttributes dict" $PROJ > /dev/null 2>&1 | |
/usr/libexec/PlistBuddy -c "Print objects:$ROOT:targets" $PROJ | tail -n +2 | head -n -1 | tr -d ' ' | while read IDENTIFIER; do | |
TARGET_NAME=$(/usr/libexec/PlistBuddy -c "Print objects:$IDENTIFIER:name" $PROJ) | |
echo "$IDENTIFIER $TARGET_NAME" | |
/usr/libexec/PlistBuddy -c "Add objects:$ROOT:attributes:TargetAttributes:$IDENTIFIER dict" $PROJ > /dev/null 2>&1 | |
/usr/libexec/PlistBuddy -c "Add objects:$ROOT:attributes:TargetAttributes:$IDENTIFIER:LastSwiftMigration string" $PROJ > /dev/null 2>&1 | |
/usr/libexec/PlistBuddy -c "Set objects:$ROOT:attributes:TargetAttributes:$IDENTIFIER:LastSwiftMigration '0800'" $PROJ > /dev/null 2>&1 | |
done | |
echo "" | |
echo "If any of the above targets should *not* have been marked as migrated, run the following." | |
echo "" | |
echo " /usr/libexec/PlistBuddy -c \"Delete objects:$ROOT:attributes:TargetAttributes:\$IDENTIFIER\" $PROJ" | |
echo " (and replace \$IDENTIFIER with the target identifier printed above)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment