A lightweight Swift workflow with Zed
I played with Swift over the weekend, and Xcode felt sluggish at times on my machine. I also had to ask Codex for help quite often just to navigate its UI.
When I tried coding in Zed, it failed to recognize structs, variables, and similar symbols defined in other project files.
A quick Google search led me to a very helpful blog post, “How I Got Zed Editor Working with Swift Projects,” and a GitHub repository: xcode-build-server.
Following the instructions in the blog post, I installed xcode-build-server and generated a buildServer.json file with the following command:
xcode-build-server config -scheme SCHEME_NAME -project PROJECT_NAME.xcodeproj
Zed could now recognize the project's symbols.
I wanted to use the simulator without opening Xcode. After some trial and error, I got hot reload working too. Here's how:
- Navigate to the project directory and run
open -a Simulator. - Run
xcodebuildto build the codebase as an.appbundle. - Run
xcrunto install and launch the built bundle in the simulator.
I've shared the Bash script I'm using in a GitHub Gist. Update the project name, scheme, directories, and other values as needed, then install fswatch to watch for file changes. Now you can run this command and have fun:
open -a Simulator && dev.sh
