Skip to content

Instantly share code, notes, and snippets.

@marc-etienne
Created September 2, 2010 15:34
Show Gist options
  • Save marc-etienne/562442 to your computer and use it in GitHub Desktop.
Save marc-etienne/562442 to your computer and use it in GitHub Desktop.
Installs iOS SDK from XCode 3 to XCode 4
#!/bin/sh
# Copyright 2010 Edovia. All rights reserved.
# Created by Marc-Etienne M.Léveillé on 02-08-10
function exit_with_message {
echo $1
exit 1
}
if [ $UID -ne 0 ]; then
echo "$0 must be run has root"
exit 2
fi
read -e -p "XCode 3 path [Default : /Developer] : " XCODE3_INSTALL_PATH
[ -z $XCODE3_INSTALL_PATH ] && XCODE3_INSTALL_PATH=/Developer
[ -d $XCODE3_INSTALL_PATH ] || exit_with_message "Path $XCODE3_INSTALL_PATH does not exists"
[ -d $XCODE3_INSTALL_PATH/Platforms/iPhoneOS.platform/Developer/SDKs ] || exit_with_message "Could not find XCode installation at $XCODE3_INSTALL_PATH"
read -e -p "XCode 4 path [Default : /Xcode4] : " XCODE4_INSTALL_PATH
[ -z $XCODE4_INSTALL_PATH ] && XCODE4_INSTALL_PATH=/Xcode4
[ -d $XCODE4_INSTALL_PATH ] || exit_with_message "Path $XCODE4_INSTALL_PATH does not exists"
[ -d $XCODE4_INSTALL_PATH/Platforms/iPhoneOS.platform/Developer/SDKs ] || exit_with_message "Could not find XCode installation at $XCODE4_INSTALL_PATH"
printf "Available iOS SDK versions : "
ls $XCODE3_INSTALL_PATH/Platforms/iPhoneOS.platform/Developer/SDKs
read -e -p "iOS SDK Version to install in XCode 4 [Default : 4.1] : " VERSION_TO_INSTALL
[ -z $VERSION_TO_INSTALL ] && VERSION_TO_INSTALL="4.1"
function install_sdk {
SUB_PATH=$1
printf "Copying $SUB_PATH..."
if [ -d $XCODE3_INSTALL_PATH/$SUB_PATH ]; then
if [ -e $XCODE4_INSTALL_PATH/$SUB_PATH ]; then
echo "Destination folder already exists"
else
cp -a $XCODE3_INSTALL_PATH/$SUB_PATH $XCODE4_INSTALL_PATH/$SUB_PATH
if [ $? -eq 0 ]; then
echo "Done"
else
echo "Some error occured while copying, did you sudo?"
fi
fi
else
echo "SDK does not seem to be installed"
fi
}
install_sdk Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$VERSION_TO_INSTALL.sdk
install_sdk Platforms/iPhoneOS.platform/DeviceSupport/$VERSION_TO_INSTALL
install_sdk Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$VERSION_TO_INSTALL.sdk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment