@@ -84,6 +84,12 @@ pub enum SdkSearchLocation {
84
84
/// if available.
85
85
CommandLineTools ,
86
86
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
+
87
93
/// Invoke `xcode-select` to find a *Developer Directory* to search.
88
94
///
89
95
/// This mechanism is intended as a fallback in case other (pure Rust) mechanisms for locating
@@ -129,6 +135,9 @@ impl Display for SdkSearchLocation {
129
135
Self :: DeveloperDirEnv => f. write_str ( "DEVELOPER_DIR environment variable" ) ,
130
136
Self :: SystemXcode => f. write_str ( "System-installed Xcode application" ) ,
131
137
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
+ }
132
141
Self :: XcodeSelect => f. write_str ( "xcode-select" ) ,
133
142
Self :: SystemXcodes => f. write_str ( "All system-installed Xcode applications" ) ,
134
143
Self :: Developer ( dir) => {
@@ -186,6 +195,15 @@ impl SdkSearchLocation {
186
195
Ok ( SdkSearchResolvedLocation :: None )
187
196
}
188
197
}
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
+ }
189
207
Self :: XcodeSelect => Ok ( SdkSearchResolvedLocation :: PlatformDirectories (
190
208
DeveloperDirectory :: from_xcode_select ( ) ?. platforms ( ) ?,
191
209
) ) ,
@@ -275,9 +293,7 @@ pub enum SdkSearchEvent {
275
293
impl Display for SdkSearchEvent {
276
294
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
277
295
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}" ) ) ,
281
297
Self :: PlatformDirectoryInclude ( path) => f. write_fmt ( format_args ! (
282
298
"searching Platform directory {}" ,
283
299
path. display( )
@@ -322,8 +338,9 @@ pub type SdkProgressCallback = fn(SdkSearchEvent);
322
338
/// 1. Use path specified by `SDKROOT` environment variable, if defined.
323
339
/// 2. Find SDKs within the Developer Directory defined by the `DEVELOPER_DIR` environment
324
340
/// 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.
327
344
///
328
345
/// Simply call [Self::location()] to register a new location. If the default locations
329
346
/// are not desirable, construct an empty instance via [Self::empty()] and register your
@@ -383,6 +400,7 @@ impl Default for SdkSearch {
383
400
locations : vec ! [
384
401
SdkSearchLocation :: SdkRootEnv ,
385
402
SdkSearchLocation :: DeveloperDirEnv ,
403
+ SdkSearchLocation :: XcodeSelectPaths ,
386
404
SdkSearchLocation :: SystemXcode ,
387
405
SdkSearchLocation :: CommandLineTools ,
388
406
] ,
@@ -617,9 +635,7 @@ impl SdkSearch {
617
635
if let Some ( cb) = & self . progress_callback {
618
636
cb ( SdkSearchEvent :: SdkFilterExclude (
619
637
sdk_path,
620
- format ! (
621
- "SDK version {sdk_version} < minimum version {min_version}"
622
- ) ,
638
+ format ! ( "SDK version {sdk_version} < minimum version {min_version}" ) ,
623
639
) ) ;
624
640
}
625
641
@@ -630,9 +646,7 @@ impl SdkSearch {
630
646
if let Some ( cb) = & self . progress_callback {
631
647
cb ( SdkSearchEvent :: SdkFilterExclude (
632
648
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}" ) ,
636
650
) ) ;
637
651
}
638
652
@@ -646,9 +660,7 @@ impl SdkSearch {
646
660
if let Some ( cb) = & self . progress_callback {
647
661
cb ( SdkSearchEvent :: SdkFilterExclude (
648
662
sdk_path,
649
- format ! (
650
- "SDK version {sdk_version} > maximum version {max_version}"
651
- ) ,
663
+ format ! ( "SDK version {sdk_version} > maximum version {max_version}" ) ,
652
664
) ) ;
653
665
}
654
666
@@ -660,9 +672,7 @@ impl SdkSearch {
660
672
if let Some ( cb) = & self . progress_callback {
661
673
cb ( SdkSearchEvent :: SdkFilterExclude (
662
674
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}" ) ,
666
676
) ) ;
667
677
}
668
678
0 commit comments