Xcode command line (2) -xcrun

Xcode Command Lines Tool

preface

As a review of the last extra meal,

libxcselect.dylib
->
_xcselect_invoke_xcrun
-> 
libxcrun.dylib
->
xcrun_main
Copy the code

We ended up finding that all Xcode Command lines would be directed to Xcrun_main, also known as xcRun.

Xcrun became the first object of discussion

xcrun

Xcrun: command line tool runner,

If xcode-select is described as a guide in multiple sets of Command Line tools,

Xcrun can be thought of as a stepping stone to a set of Command Line tools.

So man of xcrun, man xcrun

Xcode-select = xcode-select = xcode-select

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
Copy the code

The Command to which the execution is located can be found in multiple sets of Command Line Tools.

The description even mentions Xcode-select, as I said above, to walk to the actual executable,

Xcode-select (guide) and xcrun(stepping-stone) are used together.

Xcode command Line path determined by xcode-selct -s, by which xcRun locates/executes commands.

To expand on this picture from the first post:

Usage

For example, clang in Command Line Tools:

As a reference, xcode – select the path of the xcode – select – p/Applications/xcode. App/Contents/Developer

  • xcrun clang

    • This instruction is equivalent to executing the following instruction ⬇️
      • clang
      • /usr/bin/clang == (which clang
      • /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
  • xcrun --find clang

    • /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
  • xcrun --find git

    • /Applications/Xcode.app/Contents/Developer/usr/bin/git

Futher More

The usual xcrun article will probably stop here, and basically summarize: xcrun can be followed by instructions, and then follow with instructions.

Xcrun –find clang & xcrun –find git

A is/Toolchains XcodeDefault xctoolchain/usr/bin/clang

One is/usr/bin/git

The impression I get is that xcRun has a lot more paths in it than the xcode-select path!

So I want to dig deeper into XCRun with this question.

Indeed, a set of Command line Tools can be divided into three types of instructions

Three classes of instructions

The three categories are –

  • Developer
  • SDKs(Platforms)
  • ToolChain

Three categories of folder paths in Xcode

For more on the dependencies between these three categories, and the rest of xcRun’s usage, let me drag on to the next article 😅

reference:

  • b-man/xcode-tools