Perché sviluppare da remoto?
Lo sviluppo remoto con Xcode non è solo per chi non possiede un Mac. Molti team professionali usano server Mac remoti anche quando hanno macchine locali, per via dei notevoli vantaggi:
-
Server di build sempre attivo
Il tuo Mac remoto funziona 24 ore su 24, 7 giorni su 7, in un data center. Pipeline CI/CD, build notturne e test automatizzati vengono eseguiti senza tenere aperto il tuo laptop.
-
Rete a 1Gbps con traffico illimitato
Una rete di livello data center significa clonazioni git più rapide, download delle dipendenze e caricamenti degli artefatti più veloci. Le installazioni di CocoaPods e le risoluzioni di SPM avvengono in pochi secondi.
-
Ambiente uniforme
Ogni membro del team si connette alla stessa configurazione del server. Niente più problemi del tipo "funziona sulla mia macchina" causati da versioni diverse di macOS o configurazioni di Xcode.
-
Lavora da qualsiasi dispositivo
Accedi al tuo ambiente di sviluppo Xcode completo su un server macOS dedicato da un laptop Windows, un desktop Linux, un Chromebook o persino un iPad con un client SSH. Ti serve Xcode per una sola build? Noleggia un Mac mini a giornata da $14/giorno (USD, tasse escluse); disattiva il rinnovo automatico al deploy e si ferma dopo 24 ore.
Metodo 1: SSH + CLI xcodebuild
L'approccio più leggero. Modifichi il codice nel tuo editor preferito in locale (o sul server), poi compili usando xcodebuild tramite SSH. Questo metodo funziona da qualsiasi dispositivo dotato di un terminale.
Configurare le chiavi SSH
# Generate SSH key on your local machine (if you don't have one)
ssh-keygen -t ed25519 -C "dev@company.com"
# Copy your public key to the remote Mac
ssh-copy-id user@your-mac.myremotemac.com
# Configure SSH for convenience (~/.ssh/config)
Host mac-dev
HostName your-mac.myremotemac.com
User your-username
IdentityFile ~/.ssh/id_ed25519
ForwardAgent yes
ServerAliveInterval 60
ServerAliveCountMax 3
Compression yes
# Now connect with just:
ssh mac-dev
Comandi xcodebuild comuni
# List available schemes
xcodebuild -list -project MyApp.xcodeproj
# Build for iOS Simulator
xcodebuild -project MyApp.xcodeproj \
-scheme MyApp \
-destination 'generic/platform=iOS Simulator' \
clean build
# Build with workspace (CocoaPods/SPM)
xcodebuild -workspace MyApp.xcworkspace \
-scheme MyApp \
-destination 'generic/platform=iOS Simulator' \
build
# Run unit tests (use any device listed by: xcrun simctl list devices available)
xcodebuild test \
-workspace MyApp.xcworkspace \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 17,OS=latest' \
-resultBundlePath ./TestResults.xcresult
# Archive for distribution (App Store Connect requires Xcode 26 or later)
xcodebuild archive \
-workspace MyApp.xcworkspace \
-scheme MyApp \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath ./build/MyApp.xcarchive \
CODE_SIGN_IDENTITY="Apple Distribution" \
PROVISIONING_PROFILE_SPECIFIER="MyApp Distribution"
# Export IPA from archive
xcodebuild -exportArchive \
-archivePath ./build/MyApp.xcarchive \
-exportPath ./build/ipa \
-exportOptionsPlist ExportOptions.plist
# Upload to App Store Connect
xcrun altool --upload-app \
-f ./build/ipa/MyApp.ipa \
-t ios \
-u "apple-id@example.com" \
-p "@keychain:AC_PASSWORD"
Usare tmux per sessioni persistenti
Usa tmux per mantenere in esecuzione le tue build anche se la connessione SSH cade.
# Install tmux via Homebrew
brew install tmux
# Start a new tmux session
tmux new -s build
# Run your build inside tmux
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp build
# Detach from tmux: press Ctrl+B, then D
# Your build keeps running on the server
# Reconnect later
ssh mac-dev
tmux attach -t build
Metodo 2: VNC per la GUI completa
VNC ti dà pieno accesso al desktop di macOS, inclusa l'interfaccia visiva di Xcode, l'Interface Builder, i simulatori iOS in Device Hub e Instruments. È il metodo migliore quando hai bisogno dell'esperienza completa della GUI di Xcode.
Connettersi alla Condivisione schermo
# My Remote Mac serves Screen Sharing (VNC) on port 59010:
# point your VNC client at YOUR-IP:59010 and sign in with
# your macOS username and password
# On a Mac you manage yourself, turn on Screen Sharing in
# System Settings > General > Sharing. Since macOS 12.1 the
# kickstart command can no longer enable it.
# Verify Screen Sharing is running (over SSH)
sudo launchctl list | grep -i screensharing
Client VNC consigliati per sistema operativo
| Il tuo sistema operativo | Client consigliato | Note |
|---|---|---|
| Windows | RealVNC Viewer (gratuito) | Prestazioni migliori, supporta l'high-DPI di Apple |
| Linux | Remmina o TigerVNC | Remmina ha il tunneling SSH integrato |
| macOS | Condivisione schermo integrata | Apri Finder > Vai > Connessione al server > vnc:// |
| Chromebook | VNC Viewer (Chrome Web Store) | Funziona bene per l'accesso GUI di base |
| iPad/iPhone | Screens 5 o RealVNC | Gesti touch per interagire con macOS |
VNC sicuro tramite tunnel SSH
Usa sempre un tunnel SSH per le connessioni VNC per cifrare tutto il traffico.
# Create SSH tunnel for VNC (run on your LOCAL machine)
ssh -L 5900:localhost:5900 -N -f mac-dev
# Now connect your VNC client to: localhost:5900
# All traffic is encrypted through the SSH tunnel
# On Windows with PuTTY:
# Connection > SSH > Tunnels
# Source port: 5900
# Destination: localhost:5900
# Click "Add", then connect
Consigli per l'ottimizzazione di VNC
- Abbassa la risoluzione dello schermo: imposta il Mac remoto a 1920x1080 anziché Retina per un rendering più veloce.
- Riduci la profondità di colore: nel tuo client VNC, imposta la qualità del colore su Media o 16 bit per prestazioni migliori.
- Disattiva la trasparenza: sul Mac remoto, vai su Impostazioni di Sistema > Accessibilità > Schermo > Riduci trasparenza.
- Chiudi le app non necessarie: ogni finestra aperta aumenta i dati dello schermo che devono essere trasferiti.
- Usa la compressione SSH: aggiungi
Compression yesalla tua configurazione SSH per il tunnel.
Metodo 3: VS Code Remote SSH
VS Code Remote SSH ti offre il meglio di entrambi i mondi: la reattività di un editor locale con la potenza di calcolo di un Mac remoto. Le tue battute sui tasti sono locali, le tue build vengono eseguite sul server.
Installazione e configurazione
# Step 1: Install VS Code extensions
# Open VS Code and install these extensions:
# - Remote - SSH (ms-vscode-remote.remote-ssh)
# - Swift (sswg.swift-lang)
# - CodeLLDB (vadimcn.vscode-lldb) - for debugging
# Step 2: Configure SSH in ~/.ssh/config
Host mac-dev
HostName your-mac.myremotemac.com
User your-username
IdentityFile ~/.ssh/id_ed25519
ForwardAgent yes
ServerAliveInterval 60
# Step 3: Connect
# Press Ctrl+Shift+P (or Cmd+Shift+P on macOS)
# Type: "Remote-SSH: Connect to Host"
# Select: mac-dev
# VS Code installs its server component on the remote Mac
# Open your project folder
Configurare le attività di build
Crea un file .vscode/tasks.json nel tuo progetto per eseguire xcodebuild da VS Code:
{
"version": "2.0.0",
"tasks": [
{
"label": "Build iOS (Simulator)",
"type": "shell",
"command": "xcodebuild",
"args": [
"-workspace", "MyApp.xcworkspace",
"-scheme", "MyApp",
"-destination", "generic/platform=iOS Simulator",
"build"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$xcodebuild"]
},
{
"label": "Run Tests",
"type": "shell",
"command": "xcodebuild",
"args": [
"test",
"-workspace", "MyApp.xcworkspace",
"-scheme", "MyApp",
"-destination", "platform=iOS Simulator,name=iPhone 17,OS=latest"
],
"group": "test",
"problemMatcher": ["$xcodebuild"]
},
{
"label": "Clean Build",
"type": "shell",
"command": "xcodebuild",
"args": [
"-workspace", "MyApp.xcworkspace",
"-scheme", "MyApp",
"clean"
],
"problemMatcher": []
}
]
}
Ora puoi premere Ctrl+Shift+B (o Cmd+Shift+B) per avviare una build, e l'output appare nel terminale integrato di VS Code.
Supporto del linguaggio Swift in VS Code
# On the remote Mac, install SourceKit-LSP (comes with Xcode)
# Verify it's available:
xcrun sourcekit-lsp --help
# VS Code Swift extension will automatically detect SourceKit-LSP
# You get:
# - Code completion for Swift and SwiftUI
# - Jump to definition
# - Find references
# - Inline error diagnostics
# - Symbol search
Metodo 4: IDE JetBrains via SSH (Toolbox App)
JetBrains non offre più un IDE per i progetti Swift e Xcode: AppCode è stato dismesso (aggiornamenti e supporto sono terminati il 31 dicembre 2023) e Fleet non è più distribuito (dal 22 dicembre 2025). Per Swift usa Xcode via VNC o VS Code Remote SSH. Lo sviluppo remoto di JetBrains resta utile se il tuo repository contiene anche codice Kotlin Multiplatform, backend o web: la JetBrains Toolbox App si connette a un Mac via SSH e vi esegue il backend di un IDE basato su IntelliJ, mentre un thin client renderizza l'interfaccia in locale (JetBrains Gateway funziona solo con backend Linux).
Collegare un IDE JetBrains con la Toolbox App
# JetBrains Gateway only connects to Linux backends: a Mac host
# goes through the JetBrains Toolbox App instead
# Step 1: Install the Toolbox App on your local machine
# (jetbrains.com/toolbox-app)
# Step 2: Create the SSH connection
# In the Toolbox App: SSH > New SSH Connection
# Server: your-username@your-mac.myremotemac.com
# (the Toolbox App uses OpenSSH, so your ~/.ssh/config keys apply)
# Step 3: Install the IDE backend on the remote Mac
# Open the server's Tools tab and pick an IntelliJ-based IDE
# (for example IntelliJ IDEA for Kotlin Multiplatform)
# Step 4: Open your project folder on the remote Mac
# Keep editing Swift in Xcode (Method 2) or VS Code (Method 3)
Consiglio: Lo sviluppo remoto di JetBrains funziona al meglio con una connessione internet stabile (almeno 10 Mbps). Il thin client renderizza l'interfaccia in locale, quindi l'esperienza risulta reattiva anche su lunghe distanze.
Gestire la firma del codice da remoto
La firma del codice è una delle parti più complicate dello sviluppo iOS remoto. Ecco come gestire certificati e profili di provisioning sul tuo server Mac remoto.
Esportare i certificati dall'Apple Developer Portal
# Option 1: Export from existing Mac as .p12
# On your local Mac (if you have one):
# Open Keychain Access > My Certificates
# Right-click your distribution certificate > Export
# Save as .p12 with a strong password
# Transfer to remote Mac
scp ~/Desktop/Certificates.p12 mac-dev:~/
# On the remote Mac, import:
security import ~/Certificates.p12 \
-k ~/Library/Keychains/login.keychain-db \
-P "your-p12-password" \
-T /usr/bin/codesign -T /usr/bin/security
# Allow codesign access without password prompts
security set-key-partition-list \
-S apple-tool:,apple:,codesign: \
-s -k "your-login-password" \
~/Library/Keychains/login.keychain-db
# Option 2: Create new certificate on remote Mac
# Use VNC to open Xcode > Settings > Accounts
# Add your Apple ID
# Xcode manages certificates automatically
Gestione del Keychain per CI/CD
# Create a dedicated keychain for CI/CD
security create-keychain -p "keychain-password" build.keychain-db
# Set it as the default keychain
security default-keychain -s build.keychain-db
# Unlock the keychain (needed for automated builds)
security unlock-keychain -p "keychain-password" build.keychain-db
# Set keychain timeout to prevent auto-lock during builds
security set-keychain-settings -t 3600 -u build.keychain-db
# Import certificate
security import Certificates.p12 \
-k build.keychain-db \
-P "p12-password" \
-T /usr/bin/codesign
# Let codesign use the key without a prompt (needed over SSH)
security set-key-partition-list \
-S apple-tool:,apple:,codesign: \
-s -k "keychain-password" build.keychain-db
# Add to search list
security list-keychains -s build.keychain-db login.keychain-db
# Verify
security find-identity -v -p codesigning build.keychain-db
Profili di provisioning
# Download profiles from Apple Developer Portal
# Or use the xcodebuild automatic provisioning:
# Install provisioning profiles manually
# (Xcode 16 and later read them from this folder; older versions
# used ~/Library/MobileDevice/Provisioning Profiles)
mkdir -p ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/
cp MyApp_Distribution.mobileprovision \
~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/
# List installed profiles
ls ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/
# Decode profile info
security cms -D -i ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/MyApp_Distribution.mobileprovision
Strategie di sincronizzazione dei file
Scegli la giusta strategia di sincronizzazione dei file in base al tuo flusso di lavoro.
Git (consigliato)
L'approccio più semplice e affidabile. Modifica in locale, invia con push a un repository, scarica con pull sul Mac remoto.
# Local machine: push changes
git add . && git commit -m "Update views" && git push
# Remote Mac: pull and build
ssh mac-dev "cd ~/MyApp && git pull && xcodebuild build"
rsync (sincronizzazione veloce)
Sincronizza solo i file modificati tramite SSH. Più veloce che copiare intere directory.
# Sync local project to remote Mac
rsync -avz --exclude '.git' --exclude 'DerivedData' \
--exclude 'build' --exclude '.DS_Store' \
./MyApp/ mac-dev:~/MyApp/
# Watch for changes and auto-sync (using fswatch on macOS/Linux)
fswatch -o ./MyApp/Sources/ | while read; do
rsync -avz ./MyApp/Sources/ mac-dev:~/MyApp/Sources/
done
SSHFS (montare il filesystem remoto)
Monta il filesystem del Mac remoto come un'unità locale. Modifica i file come se fossero locali.
# Install SSHFS
# Linux: sudo apt install sshfs
# macOS: brew install macfuse sshfs
# Windows: Install WinFsp + SSHFS-Win
# Mount remote directory
mkdir ~/remote-mac
sshfs mac-dev:/Users/your-username/MyApp ~/remote-mac
# Edit files locally -- they are actually on the remote Mac
code ~/remote-mac
# Unmount when done
fusermount -u ~/remote-mac # Linux
umount ~/remote-mac # macOS
Consigli sulle prestazioni
Ottimizza la tua esperienza di sviluppo remoto con queste impostazioni.
Compressione SSH
Attiva la compressione nella tua configurazione SSH per ridurre il trasferimento di dati.
# ~/.ssh/config
Host mac-dev
Compression yes
CompressionLevel 6
Multiplexing SSH
Riutilizza le connessioni SSH per eliminare i ritardi di riconnessione.
# Create the socket folder once: mkdir -p ~/.ssh/sockets
# ~/.ssh/config
Host mac-dev
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
DerivedData su RAM Disk
Sposta i DerivedData di Xcode su un RAM disk per build più veloci. Mantienilo piccolo e usalo solo sui Mac con 24 GB o più: il disco viene cancellato a ogni riavvio.
# Create a 4 GB RAM disk (24 GB+ Macs only;
# it is erased at every restart)
diskutil erasevolume HFS+ \
"RAMDisk" $(hdiutil attach \
-nomount ram://8388608)
# Point Xcode DerivedData to RAM disk
defaults write com.apple.dt.Xcode \
IDECustomDerivedDataLocation \
/Volumes/RAMDisk/DerivedData
Caching locale con Mosh
Usa Mosh invece di SSH per una migliore reattività su connessioni instabili.
# Install Mosh on both machines
brew install mosh
# Connect (handles roaming and sleep)
mosh user@your-mac.myremotemac.com
Impostazioni della risoluzione VNC
# Set a lower resolution for better VNC performance
# On the remote Mac, install displayplacer (Homebrew core)
brew install displayplacer
# List current display settings (note the display id)
displayplacer list
# Apply 1920x1080, using the id shown by the list command
displayplacer "id:1 res:1920x1080 hz:60 color_depth:8 scaling:off"
Domande frequenti
Quale metodo dovrei scegliere: SSH, VNC o VS Code?
Posso usare l'anteprima SwiftUI di Xcode da remoto?
Quanta banda usa VNC?
Posso eseguire più istanze del Simulatore da remoto?
xcrun simctl per gestire le istanze del Simulatore dalla riga di comando.Cosa succede se la mia connessione SSH cade durante una build?
tmux o screen, la build continua a essere eseguita sul server e puoi riconnetterti alla sessione. Senza tmux, il processo di build verrà terminato. Consigliamo vivamente di eseguire sempre le build all'interno di una sessione tmux.