#!/bin/bash
# Installation script for iOS Dev MCP Server with Claude Code
set -e
echo "🚀 iOS Dev MCP Server - Claude Code Installation"
echo "================================================"
echo ""
# Check if we're on macOS
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "❌ Error: iOS Dev MCP Server requires macOS"
exit 1
fi
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo "❌ Error: Node.js is not installed"
echo "Please install Node.js 18+ from https://nodejs.org/"
exit 1
fi
# Check Node version
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "❌ Error: Node.js version 18 or higher is required"
echo "Current version: $(node -v)"
exit 1
fi
# Check if Xcode is installed
if ! command -v xcrun &> /dev/null; then
echo "❌ Error: Xcode Command Line Tools are not installed"
echo "Install with: xcode-select --install"
exit 1
fi
# Get the absolute path to this script's directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "📁 Project directory: $SCRIPT_DIR"
echo ""
# Build the project if not already built
if [ ! -d "$SCRIPT_DIR/build" ]; then
echo "🔨 Building project..."
cd "$SCRIPT_DIR"
npm install
npm run build
echo "✅ Build complete"
echo ""
fi
# Get Claude Code settings directory
CLAUDE_CODE_SETTINGS_DIR="$HOME/.config/claude-code"
# Create settings directory if it doesn't exist
if [ ! -d "$CLAUDE_CODE_SETTINGS_DIR" ]; then
echo "📂 Creating Claude Code settings directory..."
mkdir -p "$CLAUDE_CODE_SETTINGS_DIR"
fi
# Path to Claude Code settings file
SETTINGS_FILE="$CLAUDE_CODE_SETTINGS_DIR/settings.json"
# Create settings file if it doesn't exist
if [ ! -f "$SETTINGS_FILE" ]; then
echo "📝 Creating new settings file..."
echo '{"mcpServers":{}}' > "$SETTINGS_FILE"
fi
# Update the config with actual path
CONFIG_TEMPLATE='{
"ios-dev": {
"command": "node",
"args": ["'$SCRIPT_DIR'/build/index.js"],
"metadata": {
"name": "iOS Development MCP Server",
"description": "Comprehensive iOS simulator control and Swift/Xcode development tools",
"version": "0.1.0"
}
}
}'
# Check if jq is available for JSON manipulation
if command -v jq &> /dev/null; then
echo "🔧 Updating Claude Code settings..."
# Backup existing settings
cp "$SETTINGS_FILE" "$SETTINGS_FILE.backup"
# Add or update ios-dev server
jq --argjson server "$CONFIG_TEMPLATE" \
'.mcpServers["ios-dev"] = $server["ios-dev"]' \
"$SETTINGS_FILE" > "$SETTINGS_FILE.tmp" && \
mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE"
echo "✅ Settings updated successfully"
else
echo "⚠️ Warning: jq not found, manual configuration required"
echo ""
echo "Add this to $SETTINGS_FILE:"
echo ""
echo "$CONFIG_TEMPLATE"
fi
echo ""
echo "✅ Installation complete!"
echo ""
echo "📋 Next steps:"
echo "1. Restart Claude Code if it's running"
echo "2. The iOS Dev MCP Server tools will be available"
echo "3. Test with: 'List all iOS simulators'"
echo ""
echo "🔧 Available tools (17 currently):"
echo " Device Management:"
echo " • simulator_list_devices"
echo " • simulator_boot"
echo " • simulator_shutdown"
echo " • simulator_get_info"
echo " UI Interaction:"
echo " • simulator_screenshot"
echo " • simulator_tap"
echo " • simulator_swipe"
echo " • simulator_long_press"
echo " App Management:"
echo " • simulator_launch_app"
echo " • simulator_terminate_app"
echo " • simulator_install_app"
echo " • simulator_uninstall_app"
echo " • simulator_open_url"
echo " • simulator_get_logs"
echo " Input Simulation:"
echo " • simulator_type_text"
echo " • simulator_press_home"
echo " • simulator_send_keys"
echo ""
echo "📖 For more info, see: $SCRIPT_DIR/README.md"