@@ -84,6 +84,12 @@ pub enum SdkSearchLocation {
8484 /// if available.
8585 CommandLineTools ,
8686
87+ /// Check the paths configured by `xcode-select --switch`.
88+ ///
89+ /// This effectively controls whether the Developer Directory resolved by
90+ /// [DeveloperDirectory::from_xcode_select_paths()] will be searched, if available.
91+ XcodeSelectPaths ,
92+
8793 /// Invoke `xcode-select` to find a *Developer Directory* to search.
8894 ///
8995 /// This mechanism is intended as a fallback in case other (pure Rust) mechanisms for locating
@@ -129,6 +135,9 @@ impl Display for SdkSearchLocation {
129135 Self :: DeveloperDirEnv => f. write_str ( "DEVELOPER_DIR environment variable" ) ,
130136 Self :: SystemXcode => f. write_str ( "System-installed Xcode application" ) ,
131137 Self :: CommandLineTools => f. write_str ( "Xcode Command Line Tools installation" ) ,
138+ Self :: XcodeSelectPaths => {
139+ f. write_str ( "Internal xcode-select paths (`/var/db/xcode_select_link`)" )
140+ }
132141 Self :: XcodeSelect => f. write_str ( "xcode-select" ) ,
133142 Self :: SystemXcodes => f. write_str ( "All system-installed Xcode applications" ) ,
134143 Self :: Developer ( dir) => {
@@ -186,6 +195,15 @@ impl SdkSearchLocation {
186195 Ok ( SdkSearchResolvedLocation :: None )
187196 }
188197 }
198+ Self :: XcodeSelectPaths => {
199+ if let Some ( dir) = DeveloperDirectory :: from_xcode_select_paths ( ) ? {
200+ Ok ( SdkSearchResolvedLocation :: PlatformDirectories (
201+ dir. platforms ( ) ?,
202+ ) )
203+ } else {
204+ Ok ( SdkSearchResolvedLocation :: None )
205+ }
206+ }
189207 Self :: XcodeSelect => Ok ( SdkSearchResolvedLocation :: PlatformDirectories (
190208 DeveloperDirectory :: from_xcode_select ( ) ?. platforms ( ) ?,
191209 ) ) ,
@@ -275,9 +293,7 @@ pub enum SdkSearchEvent {
275293impl Display for SdkSearchEvent {
276294 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
277295 match self {
278- Self :: SearchingLocation ( location) => {
279- f. write_fmt ( format_args ! ( "searching {location}" ) )
280- }
296+ Self :: SearchingLocation ( location) => f. write_fmt ( format_args ! ( "searching {location}" ) ) ,
281297 Self :: PlatformDirectoryInclude ( path) => f. write_fmt ( format_args ! (
282298 "searching Platform directory {}" ,
283299 path. display( )
@@ -322,8 +338,9 @@ pub type SdkProgressCallback = fn(SdkSearchEvent);
322338/// 1. Use path specified by `SDKROOT` environment variable, if defined.
323339/// 2. Find SDKs within the Developer Directory defined by the `DEVELOPER_DIR` environment
324340/// variable.
325- /// 3. Find SDKs within the system installed `Xcode` application.
326- /// 4. Find SDKs within the system installed Xcode Command Line Tools.
341+ /// 3. Find SDKs within the path configured with `xcode-select --switch`.
342+ /// 4. Find SDKs within the system installed Xcode application.
343+ /// 5. Find SDKs within the system installed Xcode Command Line Tools.
327344///
328345/// Simply call [Self::location()] to register a new location. If the default locations
329346/// are not desirable, construct an empty instance via [Self::empty()] and register your
@@ -383,6 +400,7 @@ impl Default for SdkSearch {
383400 locations : vec ! [
384401 SdkSearchLocation :: SdkRootEnv ,
385402 SdkSearchLocation :: DeveloperDirEnv ,
403+ SdkSearchLocation :: XcodeSelectPaths ,
386404 SdkSearchLocation :: SystemXcode ,
387405 SdkSearchLocation :: CommandLineTools ,
388406 ] ,
@@ -617,9 +635,7 @@ impl SdkSearch {
617635 if let Some ( cb) = & self . progress_callback {
618636 cb ( SdkSearchEvent :: SdkFilterExclude (
619637 sdk_path,
620- format ! (
621- "SDK version {sdk_version} < minimum version {min_version}"
622- ) ,
638+ format ! ( "SDK version {sdk_version} < minimum version {min_version}" ) ,
623639 ) ) ;
624640 }
625641
@@ -630,9 +646,7 @@ impl SdkSearch {
630646 if let Some ( cb) = & self . progress_callback {
631647 cb ( SdkSearchEvent :: SdkFilterExclude (
632648 sdk_path,
633- format ! (
634- "Unknown SDK version fails to meet minimum version {min_version}"
635- ) ,
649+ format ! ( "Unknown SDK version fails to meet minimum version {min_version}" ) ,
636650 ) ) ;
637651 }
638652
@@ -646,9 +660,7 @@ impl SdkSearch {
646660 if let Some ( cb) = & self . progress_callback {
647661 cb ( SdkSearchEvent :: SdkFilterExclude (
648662 sdk_path,
649- format ! (
650- "SDK version {sdk_version} > maximum version {max_version}"
651- ) ,
663+ format ! ( "SDK version {sdk_version} > maximum version {max_version}" ) ,
652664 ) ) ;
653665 }
654666
@@ -660,9 +672,7 @@ impl SdkSearch {
660672 if let Some ( cb) = & self . progress_callback {
661673 cb ( SdkSearchEvent :: SdkFilterExclude (
662674 sdk_path,
663- format ! (
664- "Unknown SDK version fails to meet maximum version {max_version}"
665- ) ,
675+ format ! ( "Unknown SDK version fails to meet maximum version {max_version}" ) ,
666676 ) ) ;
667677 }
668678
0 commit comments