You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新Xcode命令行工具后,如何不关闭会话刷新Terminal/iTerm?

解决不重启iTerm2即可刷新Xcode命令行工具环境的问题

Hey there! I totally get why you don't want to interrupt that 7-hour upload—let's fix the tns build ios error without closing your active session. Here are a few actionable steps:

1. 手动更新Xcode命令行工具路径并刷新环境变量

First, check if your terminal is using the correct Xcode developer path:

xcode-select -p

If it doesn't return /Applications/Xcode.app/Contents/Developer, update it with:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Then reload your shell's configuration to apply changes immediately (pick the one matching your shell):

  • For Bash:
    source ~/.bash_profile
    
  • For Zsh (default on newer macOS):
    source ~/.zshrc
    

2. 初始化Xcode命令行工具会话

Sometimes Xcode needs a post-update initialization that doesn't require a terminal restart. Run this command to trigger it:

xcodebuild -runFirstLaunch

This will complete any setup steps the command line tools need, making the updated version available in your current session.

3. 手动导出DEVELOPER_DIR环境变量

NativeScript might rely on the DEVELOPER_DIR variable to locate Xcode tools. Export it directly in your current session:

export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer

After running this, try your tns build ios command again—it should pick up the updated tools.

处理前台运行的上传会话

If your upload is running in the foreground of your terminal, you can temporarily move it to the background to run the above commands:

  1. Press Ctrl+Z to pause the upload.
  2. Type bg and hit Enter to resume it in the background.
  3. Run the environment-fix commands listed above.
  4. If you want the upload back in the foreground, type fg and hit Enter.

This won't interrupt the upload (it stays running in the same terminal session) and lets you refresh the Xcode tool environment.

Before re-running tns build ios, verify the fix by checking the Xcode version:

xcodebuild -version

It should show the latest version you installed—if it does, your NativeScript build should work now!

内容的提问来源于stack exchange,提问作者Hang Chen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:21:18