indygreg / apple-platform-rs

Rust crates supporting Apple platform development
595 stars 49 forks source link

apple-sdk: support reading path set by `xcode-select --switch` #154

Closed madsmtm closed 3 weeks ago

madsmtm commented 3 months ago

The user can set the current developer directory globally by using xcode-select --switch PATH.

This creates a symlink at /var/db/xcode_select_link, which we can read to get the path of the current globally configured developer directory. In the past, other files were created instead, so we also attempt to read those (we could probably omit this logic, but might as well include it for completeness).

I'm fairly confident that this is the last thing needed for SdkSearch::default() to perform exactly the same lookup as xcode-select --print-path itself.

See also https://github.com/rust-lang/rust/pull/131433 where I implemented similar logic in rustc.

madsmtm commented 3 months ago

I have since making this become aware that /usr/share/xcode-select is protected by SIP, so it’s likely only used internally for development - I'll do the work to remove it from the PR if there is desire to land this?