#!/bin/bash # Fix iPhone Mirroring connection issues set -e echo "🔧 Fixing iPhone Mirroring issues..." echo "" # Check macOS version echo "📱 Checking macOS version..." MACOS_VERSION=$(sw_vers -productVersion | cut -d. -f1) if [ "$MACOS_VERSION" -lt 15 ]; then echo "❌ Error: iPhone Mirroring requires macOS Sequoia 15.0 or later" echo " Current version: $(sw_vers -productVersion)" exit 1 fi echo "✅ macOS version OK: $(sw_vers -productVersion)" echo "" # Enable Handoff/Continuity echo "🔄 Enabling Handoff and Continuity features..." defaults write com.apple.coreservices.useractivityd.plist ActivityAdvertisingAllowed -bool true defaults write com.apple.coreservices.useractivityd.plist ActivityReceivingAllowed -bool true echo "✅ Handoff enabled" echo "" # Restart Continuity services echo "🔄 Restarting Continuity services..." killall sharingd 2>/dev/null || true killall bluetoothd 2>/dev/null || true sleep 2 # Restart Bluetooth daemon echo "🔄 Restarting Bluetooth..." sudo launchctl stop com.apple.bluetoothd 2>/dev/null || true sleep 1 sudo launchctl start com.apple.bluetoothd 2>/dev/null || true echo "✅ Services restarted" echo "" # Check Bluetooth and Wi-Fi status echo "📡 Checking connectivity..." BLUETOOTH_STATUS=$(system_profiler SPBluetoothDataType 2>/dev/null | grep -i "state" | head -1 | grep -i "on" && echo "On" || echo "Off") WIFI_STATUS=$(networksetup -getairportpower en0 2>/dev/null | grep -i "on" && echo "On" || echo "Off") if [ "$BLUETOOTH_STATUS" = "On" ]; then echo "✅ Bluetooth is enabled" else echo "⚠️ Bluetooth is disabled - please enable it in System Settings" fi if [ "$WIFI_STATUS" = "On" ]; then echo "✅ Wi-Fi is enabled" else echo "⚠️ Wi-Fi is disabled - please enable it in System Settings" fi echo "" # Verify Handoff settings echo "✅ Verifying Handoff settings..." ADVERTISING=$(defaults read com.apple.coreservices.useractivityd.plist ActivityAdvertisingAllowed 2>/dev/null || echo "false") RECEIVING=$(defaults read com.apple.coreservices.useractivityd.plist ActivityReceivingAllowed 2>/dev/null || echo "false") if [ "$ADVERTISING" = "1" ] && [ "$RECEIVING" = "1" ]; then echo "✅ Handoff is properly configured" else echo "❌ Handoff configuration incomplete" echo " ActivityAdvertisingAllowed: $ADVERTISING" echo " ActivityReceivingAllowed: $RECEIVING" fi echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "✅ Fix script completed!" echo "" echo "📋 Next steps:" echo " 1. Make sure your iPhone is:" echo " - Running iOS 18.0 or later" echo " - Unlocked and near this Mac" echo " - Signed in to the SAME iCloud account" echo " - Has Bluetooth and Wi-Fi enabled" echo "" echo " 2. Restart your Mac (recommended):" echo " sudo reboot" echo "" echo " 3. After restart, try iPhone Mirroring again" echo "" echo " 4. If still not working, check:" echo " - System Settings → General → AirDrop & Handoff" echo " → Ensure 'Handoff' is enabled" echo " - System Settings → Privacy & Security → Bluetooth" echo " → Ensure Bluetooth access is granted" echo " - System Settings → Network → Firewall" echo " → Temporarily disable to test" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"