How to check if command line tools is installed

后端 未结 10 2130
执念已碎
执念已碎 2020-11-30 18:02

I have a macbook pro with OS X 10.8.2. XCode is installed. I know this as it appears in the Applications directory. There are also the xcodebuild and xcode-select files in /

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 18:32

    Because Xcode subsumes the CLI tools if installed first, I use the following hybrid which has been validated on 10.12 and 10.14. I expect it works on a lot of other versions:

    installed=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables 2>/dev/null || pkgutil --pkg-info=com.apple.pkg.Xcode)

    Salt with awk to taste for branching logic.

    Of course xcode-select -p handles the variations with a really short command but fails to give the detailed package, version, and installation date metadata.

提交回复
热议问题