ガイド - リモート開発

リモートXcode開発:完全セットアップガイド

リモートMacサーバーでiOSおよびmacOSアプリを開発するための完全ガイド。SSH、VNC、VS Code Remote SSH、JetBrains Gatewayで接続し、シームレスなリモートXcodeワークフローを実現する方法を学びます。

読了時間35分 2026年3月更新

なぜリモートで開発するのか?

リモートXcode開発は、Macを持っていない人だけのものではありません。多くのプロフェッショナルなチームは、ローカルマシンを持っていてもリモートMacサーバーを使っています。それには大きな利点があるからです:

常時稼働のビルドサーバー

リモートMacはデータセンターで24時間365日稼働します。CI/CDパイプライン、夜間ビルド、自動テストが、ノートPCを開いたままにしなくても実行されます。

1Gbpsネットワーク

データセンター級のネットワークにより、gitのクローン、依存関係のダウンロード、成果物のアップロードが高速になります。CocoaPodsのインストールやSPMの解決が数秒で完了します。

一貫した環境

チームの全員が同じサーバー構成に接続します。異なるmacOSバージョンやXcode設定に起因する「自分のマシンでは動く」問題はもうありません。

どんなデバイスからでも作業

Windowsノート、Linuxデスクトップ、Chromebook、さらにはSSHクライアントを備えたiPadからでも、完全なXcode開発環境にアクセスできます。

方法1:SSH + xcodebuild CLI

最も軽量なアプローチです。お好みのエディタでローカル(またはサーバー上)でコードを編集し、SSH経由でxcodebuildを使ってビルドします。この方法はターミナルを備えたあらゆるデバイスで機能します。

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

よく使うxcodebuildコマンド

# List available schemes
xcodebuild -list -project MyApp.xcodeproj

# Build for iOS Simulator
xcodebuild -project MyApp.xcodeproj \
  -scheme MyApp \
  -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.2' \
  clean build

# Build with workspace (CocoaPods/SPM)
xcodebuild -workspace MyApp.xcworkspace \
  -scheme MyApp \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  build

# Run unit tests
xcodebuild test \
  -workspace MyApp.xcworkspace \
  -scheme MyApp \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  -resultBundlePath ./TestResults.xcresult

# Archive for distribution
xcodebuild archive \
  -workspace MyApp.xcworkspace \
  -scheme MyApp \
  -configuration Release \
  -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"

永続セッションのためのtmuxの使用

SSH接続が切れてもビルドを継続させるには、tmuxを使います。

# 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

方法2:フルGUIのためのVNC

VNCを使うと、Xcodeのビジュアルインターフェース、Interface Builder、iOSシミュレータ、Instrumentsを含むmacOSデスクトップにフルアクセスできます。完全なXcode GUI体験が必要なときに最適な方法です。

macOSで画面共有を有効にする

# Enable Screen Sharing via command line
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
  -activate -configure -access -on \
  -restart -agent -privs -all

# Alternatively, set a VNC password
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
  -activate -configure -access -on \
  -clientopts -setvnclegacy -vnclegacy yes \
  -clientopts -setvncpw -vncpw "your-vnc-password" \
  -restart -agent -privs -all

# Verify Screen Sharing is running
sudo launchctl list | grep -i screen

OS別の推奨VNCクライアント

お使いのOS 推奨クライアント 備考
Windows RealVNC Viewer(無料) 最高のパフォーマンス。AppleのHigh-DPIに対応
Linux Remmina または TigerVNC RemminaはSSHトンネリングを内蔵
macOS 内蔵の画面共有 Finder >「移動」>「サーバへ接続」> vnc:// を開く
Chromebook VNC Viewer(Chrome Web Store) 基本的なGUIアクセスには十分機能する
iPad/iPhone Screens 5 または RealVNC macOS操作のためのタッチジェスチャー

SSHトンネルでVNCを安全にする

すべてのトラフィックを暗号化するため、VNC接続には常にSSHトンネルを使いましょう。

# 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

VNC最適化のヒント

  • 画面解像度を下げる:レンダリングを高速化するため、リモートMacをRetinaではなく1920x1080に設定します。
  • 色深度を下げる:パフォーマンス向上のため、VNCクライアントで色品質を「中」または16ビットに設定します。
  • 透明度を無効にする:リモートMacで、システム設定 >「アクセシビリティ」>「ディスプレイ」>「透明度を下げる」を選択します。
  • 不要なアプリを閉じる:開いているウィンドウが増えるほど、転送が必要な画面データが増えます。
  • SSH圧縮を使う:トンネル用のSSH configにCompression yesを追加します。

方法3:VS Code Remote SSH

VS Code Remote SSHは、両方の長所を提供します。ローカルエディタの応答性と、リモートMacの処理能力です。キー入力はローカルで、ビルドはサーバー上で実行されます。

インストールと設定

# 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

ビルドタスクの設定

VS Codeからxcodebuildを実行するために、プロジェクトに.vscode/tasks.jsonを作成します:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build iOS (Simulator)",
            "type": "shell",
            "command": "xcodebuild",
            "args": [
                "-workspace", "MyApp.xcworkspace",
                "-scheme", "MyApp",
                "-destination", "platform=iOS Simulator,name=iPhone 16",
                "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 16"
            ],
            "group": "test",
            "problemMatcher": ["$xcodebuild"]
        },
        {
            "label": "Clean Build",
            "type": "shell",
            "command": "xcodebuild",
            "args": [
                "-workspace", "MyApp.xcworkspace",
                "-scheme", "MyApp",
                "clean"
            ],
            "problemMatcher": []
        }
    ]
}

これでCtrl+Shift+B(またはCmd+Shift+B)を押すとビルドが実行され、出力がVS Codeの統合ターミナルに表示されます。

VS CodeでのSwift言語サポート

# 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

方法4:JetBrains Gateway + AppCode

JetBrains Gatewayは、VS Code Remoteに似たリモート開発体験を、JetBrains IDEエコシステムで提供します。AppCodeは提供終了となりましたが、JetBrains Fleetや、他のJetBrains IDEでGatewayを利用できます。

JetBrains Gatewayを設定する

# Step 1: Download JetBrains Gateway from jetbrains.com/remote-development/gateway/

# Step 2: Configure SSH connection
# In Gateway: New Connection > SSH
# Host: your-mac.myremotemac.com
# User: your-username
# Authentication: Key pair (select your private key)

# Step 3: Select IDE Backend
# Choose "IntelliJ IDEA" or "Fleet" to run on the remote Mac
# Gateway downloads and installs the IDE backend on the server

# Step 4: Open your project
# Navigate to your project folder on the remote Mac
# The IDE opens with full language support and indexing

ヒント:JetBrains Gatewayは安定したインターネット接続(最低10 Mbps)で最も快適に動作します。シンクライアントがUIをローカルでレンダリングするため、遠距離でも軽快に感じられます。

リモートでのコード署名の管理

コード署名は、リモートiOS開発で最も厄介な部分の一つです。ここでは、リモートMacサーバーで証明書とプロビジョニングプロファイルを管理する方法を説明します。

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

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

# Add to search list
security list-keychains -s build.keychain-db login.keychain-db

# Verify
security find-identity -v -p codesigning build.keychain-db

プロビジョニングプロファイル

# Download profiles from Apple Developer Portal
# Or use the xcodebuild automatic provisioning:

# Install provisioning profiles manually
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles/
cp MyApp_Distribution.mobileprovision \
  ~/Library/MobileDevice/Provisioning\ Profiles/

# List installed profiles
ls ~/Library/MobileDevice/Provisioning\ Profiles/

# Decode profile info
security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/MyApp_Distribution.mobileprovision

ファイル同期の戦略

ワークフローに応じて、適切なファイル同期戦略を選びましょう。

Git(推奨)

最もシンプルで信頼性の高いアプローチです。ローカルで編集し、リポジトリにプッシュして、リモートMacでプルします。

# 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(高速同期)

SSH経由で変更されたファイルのみを同期します。ディレクトリ全体をコピーするより高速です。

# 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(リモートファイルシステムのマウント)

リモートMacのファイルシステムをローカルドライブとしてマウントします。ローカルにあるかのようにファイルを編集できます。

# 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

パフォーマンスのヒント

これらの設定でリモート開発体験を最適化しましょう。

SSH圧縮

データ転送を削減するため、SSH configで圧縮を有効にします。

# ~/.ssh/config
Host mac-dev
    Compression yes
    CompressionLevel 6

SSH多重化

SSH接続を再利用して、再接続の遅延をなくします。

# ~/.ssh/config
Host mac-dev
    ControlMaster auto
    ControlPath ~/.ssh/sockets/%r@%h-%p
    ControlPersist 600

RAMディスク上のDerivedData

ビルドを高速化するため、XcodeのDerivedDataをRAMディスクに移動します。

# Create 8GB RAM disk
diskutil erasevolume HFS+ \
  "RAMDisk" $(hdiutil attach \
  -nomount ram://16777216)

# Point Xcode DerivedData to RAM disk
defaults write com.apple.dt.Xcode \
  IDECustomDerivedDataLocation \
  /Volumes/RAMDisk/DerivedData

Moshによるローカルキャッシュ

不安定な接続での応答性を高めるため、SSHの代わりにMoshを使います。

# Install Mosh on both machines
brew install mosh

# Connect (handles roaming and sleep)
mosh user@your-mac.myremotemac.com

VNC解像度の設定

# Set a lower resolution for better VNC performance
# On the remote Mac:
sudo displayplacer "id:1 res:1920x1080 hz:60 color_depth:8 scaling:off"

# Install displayplacer if needed
brew tap jakehilborn/jakehilborn
brew install displayplacer

# List current display settings
displayplacer list

よくある質問

SSH、VNC、VS Codeのどれを選ぶべきですか?

ほとんどの開発者は組み合わせて使っています。日々のコーディングにはVS Code Remote SSH(最高の編集体験)、手早いビルドやスクリプトにはSSH、Interface BuilderやシミュレータのGUIが必要なときにはVNCです。まずはVS Code Remote SSHから始め、必要に応じてVNCを追加しましょう。

XcodeのSwiftUIプレビューをリモートで使えますか?

はい。ただしSwiftUIプレビューにはXcode GUIが必要なため、VNC経由でのみ可能です。VNCで接続し、Xcodeでプロジェクトを開き、いつもどおりキャンバスプレビューを使います。プレビューはリモートMac上でリアルタイムに更新されます。

VNCはどれくらいの帯域幅を使いますか?

VNCは1920x1080での通常の開発作業では、一般的に1〜5 Mbpsを使用します。活発なスクロールやアニメーションでは10〜15 Mbpsまで跳ね上がることがあります。25 Mbpsの接続があれば、一日中VNCを使っても快適です。SSHとVS Code Remoteは、はるかに少ない帯域幅(1 Mbps未満)しか使いません。

リモートで複数のシミュレータインスタンスを実行できますか?

はい。Mac Mini M4は、複数のシミュレータインスタンスを同時に実行するのに十分なRAMとCPUコアを備えています。これは、異なるiPhoneモデルのテストや、並列UIテストの実行に便利です。コマンドラインからシミュレータのインスタンスを管理するにはxcrun simctlを使います。

ビルド中にSSH接続が切れたらどうなりますか?

tmuxscreenを使っていれば、ビルドはサーバー上で実行され続け、セッションに再アタッチできます。tmuxがなければ、ビルドプロセスは終了してしまいます。ビルドは常にtmuxセッション内で実行することを強くお勧めします。

リモートXcode開発を始める準備はできましたか?

フルルートアクセス、1Gbpsネットワーク、24時間365日の稼働を備えた専用Mac Mini M4を手に入れましょう。Xcodeのビルドがこれ以上速くなることはないでしょう。

関連ガイド

さらに詳しい情報をお探しですか?

ステップバイステップのセットアップ手順、設定リファレンス、トラブルシューティングについては、完全なドキュメントをご覧ください。

ドキュメントを開く →