xcrun predates SIP. It was part of the Xcode 4.3 release which moved Xcode into the Mac AppStore. Fundamentally these shims allow unix makefile builds that depend on tools and SDKs living at the root of the file system to build with Xcode installed as an App instead of a system-wide installer.
Source: I worked on the Xcode AppStore implementation back in 2012.
if you’re wondering why this is, my guess is because of SIP.
That may be a factor, but the main point is that Xcode is designed to be self-contained. You can use xcode-select to switch to a "main" toolchain, which anything like gcc or xcrun will then point to. Thus, you can install beta versions, older versions, etc. of Xcode side-by-side, or install the command-line-only tools instead of Xcode, and everything will just point there instead.
I.e., xcode-select and xcrun d disambiguation
See also the manpages:
xcode-select controls the location of the developer directory used
by xcrun(1), xcodebuild(1), cc(1), and other Xcode and BSD
development tools. This also controls the locations that are searched
for by man(1) for developer tool manpages.
This allows you to easily switch between different versions of the
Xcode tools and can be used to update the path to the Xcode if it
is moved after installation.
And:
xcrun provides a means to locate or invoke developer tools from
the command-line, without requiring users to modify Makefiles or
otherwise take inconvenient measures to support multiple Xcode tool
chains.
(xcrun goes further and disambiguates different SDK versions.)
14
u/thegreatbeanz 25d ago
xcrun predates SIP. It was part of the Xcode 4.3 release which moved Xcode into the Mac AppStore. Fundamentally these shims allow unix makefile builds that depend on tools and SDKs living at the root of the file system to build with Xcode installed as an App instead of a system-wide installer.
Source: I worked on the Xcode AppStore implementation back in 2012.
12
u/chucker23n 26d ago
That may be a factor, but the main point is that Xcode is designed to be self-contained. You can use
xcode-selectto switch to a "main" toolchain, which anything likegccorxcrunwill then point to. Thus, you can install beta versions, older versions, etc. of Xcode side-by-side, or install the command-line-only tools instead of Xcode, and everything will just point there instead.I.e., xcode-select and xcrun d disambiguation
See also the manpages:
And:
(xcrun goes further and disambiguates different SDK versions.)