Created
March 16, 2023 00:56
-
-
Save toshi0383/f24ad1727680a95c6e99892af77d0ecd to your computer and use it in GitHub Desktop.
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 | |
# プロジェクトファイルのパス | |
PROJECT_PATH="YourProject.xcodeproj" | |
# スキーム名 | |
SCHEME_NAME="YourScheme" | |
# シミュレータのデバイス名 | |
SIMULATOR_DEVICE_NAME="iPhone 12" | |
# シミュレータのランタイムID | |
SIMULATOR_RUNTIME_ID="com.apple.CoreSimulator.SimRuntime.iOS-15-0" | |
# シミュレータのデバイスIDを取得 | |
SIMULATOR_DEVICE_ID=$(xcrun simctl list devices | grep -w "$SIMULATOR_DEVICE_NAME" | grep -o -E "([0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})") | |
# シミュレータが見つからない場合、新しいシミュレータを作成 | |
if [ -z "$SIMULATOR_DEVICE_ID" ]; then | |
echo "Creating a new simulator device..." | |
SIMULATOR_DEVICE_ID=$(xcrun simctl create "$SIMULATOR_DEVICE_NAME" "$SIMULATOR_RUNTIME_ID") | |
fi | |
# ビルド | |
echo "Building project..." | |
xcodebuild -project "$PROJECT_PATH" -scheme "$SCHEME_NAME" -sdk iphonesimulator -derivedDataPath "./build" -configuration Debug | |
# シミュレータでアプリを実行 | |
APP_PATH="./build/Build/Products/Debug-iphonesimulator/YourApp.app" | |
echo "Starting simulator and running app..." | |
xcrun simctl boot "$SIMULATOR_DEVICE_ID" | |
xcrun simctl install "$SIMULATOR_DEVICE_ID" "$APP_PATH" | |
xcrun simctl launch "$SIMULATOR_DEVICE_ID" "$(basename "$APP_PATH" .app)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment