Xcode Command Lines Tool 知识点记录

Xcode Command Lines Tool 是什么

Xcode Command Lines Tool 是终端下xcode开发相关的命令行工具集合。Command Lines Tool这里我们简写为CLT

关键知点

CTL可以有多套,系统默认一个,Xcode IDE自带一个

系统默认的CTL路径为:/Library/Developer/
Xcode IDE的CTL路径为:/Applications/Xcode.app/Contents/Developer

Xcode-Select 可以切换CTL

由于可以存在多配套CLT,所以就存在切换环境的需求,即Xcode-Select就是为此而存在的

$ xcode-select -h
Usage: xcode-select [options]

Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).

Options:
  -h, --help                  print this help message and exit
  -p, --print-path            print the path of the active developer directory
  -s <path>, --switch <path>  set the path for the active developer directory
  --install                   open a dialog for installation of the command line developer tools
  -v, --version               print the xcode-select version
  -r, --reset                 reset to the default command line tools path

-p可以查看当前CLT的路径

 xcode-select -p
/Applications/Xcode.app/Contents/Developer
//感觉是安装xcode13后,会是指向xcode13下的CLT

xcrun 可以运行当前CTL下的某个命令

xcrun -h
Usage: xcrun [options] <tool name> ... arguments ...

Find and execute the named command line tool from the active developer
directory.

The active developer directory can be set using `xcode-select`, or via the
DEVELOPER_DIR environment variable. See the xcrun and xcode-select manual
pages for more information.

Options:
  -h, --help                  show this help message and exit
  --version                   show the xcrun version
  -v, --verbose               show verbose logging output
  --sdk <sdk name>            find the tool for the given SDK name
  --toolchain <name>          find the tool for the given toolchain
  -l, --log                   show commands to be executed (with --run)
  -f, --find                  only find and print the tool path
  -r, --run                   find and execute the tool (the default behavior)
  -n, --no-cache              do not use the lookup cache
  -k, --kill-cache            invalidate all existing cache entries
  --show-sdk-path             show selected SDK install path
  --show-sdk-version          show selected SDK version
  --show-sdk-build-version    show selected SDK build version
  --show-sdk-platform-path    show selected SDK platform path
  --show-sdk-platform-version show selected SDK platform version

参考文档

### Xcode 15 中配置 Command Line Tools 的教程 在 macOS 开发环境中,Xcode 提供了一组强大的开发工具集,其中包括 Command Line Tools。以下是关于如何在 Xcode 15 中配置这些工具的具体方法: #### 安装 Command Line Tools 要安装 Xcode Command Line Tools,可以通过终端执行以下命令完成初始安装: ```bash xcode-select --install ``` 此命令会触发一个图形化界面提示用户确认安装请求[^1]。 #### 验证安装状态 一旦安装完成后,可通过验证路径是否存在来判断安装是否成功: ```bash xcode-select -p ``` 如果返回 `/Library/Developer/CommandLineTools` 则说明已正确安装[^2]。 #### 使用 Xcode 进行进一步验证 另一种方式是通过启动 Xcode 并创建一个新的项目来进行测试。当打开 Xcode 后,在新建项目的选项中选择 macOS 应用程序类别下的 **Command Line Tool** 图标时,如果没有报错,则表明环境已经正常加载了所需的工具链[^3]。 #### 版本检查 为了确保当前使用的 `xcode-select` 是最新版本或者支持的功能符合预期需求,可以运行如下指令查看其版本号信息: ```bash xcode-select --version ``` 这一步骤有助于开发者了解所依赖的基础组件情况[^4]。 #### 解决潜在问题 假如遇到某些异常状况比如链接错误或者其他与 CLT 相关的问题时,可能需要重置 xcode-select 设置回到出厂默认值再重新指定新的 SDK 路径等操作。具体做法如下所示: ```bash sudo xcode-select --reset ``` 上述动作需管理员权限才能生效,并且它能够帮助清除掉之前残留的数据从而让系统再次扫描最新的可用资源位置[^5]。 ### 总结 综上所述,对于想要学习怎样于 Xcode 15 上面适配好 Command Line Tools 的朋友们来说,按照以上几个方面去实践应该就可以顺利完成整个过程啦!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值