Open2
Dev Container上でSwiftのライブラリをClaude Codeを使いながら開発する時の環境周りをまとめるやーつ
devcontainer.json
ちょいちょい変えているので都度更新する。
- Swiftのバージョンは任意
- Claude CodeはDev Container Featuresで入れる
-
runArgs
の-v
,-e
とpostStartCommand
は1PasswordでSSH署名をする場合に必要
{
"name": "Swift",
"image": "swift:6.1",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"upgradePackages": "false"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
},
"ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"-v", "/run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock",
"-e", "SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock"
],
"postStartCommand": "git config --global --unset gpg.ssh.program || true",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.library": "/usr/lib/liblldb.so"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"swiftlang.swift-vscode"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
Linux上のFoundationにURLSession.bytesが含まれていない問題対策
Foundationというか、FoundationNetworkにURLSessionが入っているが、 bytes
がないのでバイトストリームが処理できない問題がある。swift-server/async-http-client
はちょっとAPIインターフェースが好みじゃないのでURLSessionっぽく使えるライブラリを書いて対応した。
dependencies: [
.package(url: "https://github.com/fumito-ito/AsyncHTTPKit.git", from: "0.0.1")
]
インターフェースはURLSessionリスペクトで、テストを書きやすくするという点でAPIKitをリスペクトしている。