2

私は iPhone アプリを開発していますが、開発の初期段階では、シミュレーターからアプリを削除してアプリのデータをリセットする必要があることがよくあります。ソースをクリーンアップするときに XCode にこれを自動的に実行させたいのですが、これを行う方法がわかりません。

4

1 に答える 1

3

この投稿の助けを借りて、これを行う方法を見つけました。外部ビルド スクリプトをプロジェクトの依存関係として設定すると、プロジェクトをクリーンアップするときにスクリプトを実行できます。

その投稿は時代遅れだったので、XCode 4.5 の新しい手順を書きました。 http://nerglish.tumblr.com/post/40191311173/delete-app-from-simulator-when-cleaning-in-xcode

シミュレーターからアプリを削除するために私が書いたスクリプトは次のとおりです

#!/bin/bash

# DeleteApp.sh
#
# Deletes iPhone app from the iOS Simulator when called with the clean action
#

APP_NAME="$PROJECT_NAME.app"

buildAction () {
echo "Building..."

# Don't do anything when building

}

cleanAction () {
echo "Cleaning..."

echo "Killing iPhone Simulator"
killall "iPhone Simulator"

# Change IFS to preserve spaces in the paths
IFS=$(echo -en "\n\b")
for appDir in $(find "/Users/$USER/Library/Application Support/iPhone Simulator"/*/Applications -name "$APP_NAME")
do
    dir=$(dirname "$appDir")
    echo "Deleting $dir"
    rm -rf "$dir"
done
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# MAIN

echo "Running with ACTION=${ACTION}"

case $ACTION in
# NOTE: for some reason, it gets set to "" rather than "build" when
# doing a build.
"")
buildAction
;;

"clean")
cleanAction
;;
esac

exit 0
于 2013-01-10T20:00:42.723 に答える