為 macOS 建置 Zed
儲存庫
複製 Zed 儲存庫.
依賴項
安裝後請確保啟動 XCode,並安裝 macOS 元件,這是預設選項。
-
安裝 Xcode 命令列工具
xcode-select --install
-
確保 Xcode 命令列工具使用的是新安裝的 Xcode 副本
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
-
安裝 Rust wasm 工具鏈
rustup target add wasm32-wasi
後端依賴項
如果您正在開發 Zed 的協作功能,則需要安裝 Zed 的 collab
伺服器的依賴項
或者,如果您安裝了 Docker,則可以使用 Docker Compose 啟動所有 collab
依賴項
docker compose up -d
從原始碼建置 Zed
安裝依賴項後,您可以使用 Cargo 建置 Zed。
對於除錯版本
cargo run
對於發行版本
cargo run --release
以及執行測試
cargo test --workspace
疑難排解
編譯 Metal 著色器錯誤
error: failed to run custom build command for gpui v0.1.0 (/Users/path/to/zed)`**
xcrun: error: unable to find utility "metal", not a developer tool or in PATH
嘗試 sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Cargo 錯誤聲稱依賴項正在使用不穩定的功能
嘗試 cargo clean
和 cargo build
。
錯誤:找不到 'dispatch/dispatch.h' 檔案
如果您遇到類似以下的錯誤
src/platform/mac/dispatch.h:1:10: fatal error: 'dispatch/dispatch.h' file not found
Caused by:
process didn't exit successfully
--- stdout
cargo:rustc-link-lib=framework=System
cargo:rerun-if-changed=src/platform/mac/dispatch.h
cargo:rerun-if-env-changed=TARGET
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64-apple-darwin
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
此檔案是 Xcode 的一部分。請確保您已安裝 Xcode 命令列工具並設定了正確的路徑
xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
此外,設定 BINDGEN_EXTRA_CLANG_ARGS
環境變數
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$(xcrun --show-sdk-path)"
然後清理並重建專案
cargo clean
cargo run