@@ -637,20 +637,6 @@ void process(NSString *path, void(^dylibVisitor)(NSString *),
637
637
}
638
638
639
639
640
- @implementation NSString (sst)
641
- -(NSString *)sst_stringByAppendingPathComponents : (NSArray *)components
642
- {
643
- NSString *result = self;
644
- @autoreleasepool {
645
- for (NSString *component in components) {
646
- result = [result stringByAppendingPathComponent: component];
647
- }
648
- [result retain ];
649
- }
650
- return [result autorelease ];
651
- }
652
- @end
653
-
654
640
@implementation NSTask (sst)
655
641
-(NSString *)sst_command {
656
642
NSMutableString *command = [self .launchPath mutableCopy ];
@@ -985,10 +971,22 @@ int main(int argc, const char *argv[])
985
971
// Use platform to set src_dirs relative to us.
986
972
NSString *root_path = [[self_executable stringByDeletingLastPathComponent ]
987
973
stringByDeletingLastPathComponent ];
988
- src_dirs = [@[
989
- [root_path sst_stringByAppendingPathComponents: @[ @" lib" , @" swift-5.0" , platform ]],
990
- [root_path sst_stringByAppendingPathComponents: @[ @" lib" , @" swift-5.5" , platform ]],
991
- ] mutableCopy ];
974
+ NSURL *root_url = [[NSURL fileURLWithPath: root_path isDirectory: YES ]
975
+ URLByAppendingPathComponent: @" lib" ];
976
+ NSArray <NSURL *> *URLs = [
977
+ fm contentsOfDirectoryAtURL: root_url
978
+ includingPropertiesForKeys: @[NSURLNameKey , NSURLIsDirectoryKey ]
979
+ options: NSDirectoryEnumerationSkipsHiddenFiles error: nil ];
980
+
981
+ for (NSURL *URL in URLs) {
982
+ if ([URL.lastPathComponent hasPrefix: @" swift-" ]) {
983
+ [src_dirs addObject: [[URL URLByAppendingPathComponent: platform] path ]];
984
+ }
985
+ }
986
+
987
+ if (![src_dirs count ]) {
988
+ fail (" Couldn't discover Swift library directories in: %s" , root_path.fileSystemRepresentation );
989
+ }
992
990
} else if (!platform) {
993
991
// src_dirs is set but platform is not.
994
992
// Pick platform from any src_dirs' name.
0 commit comments