forked from RimoChan/match-you
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mother.swift
25 lines (18 loc) · 987 Bytes
/
mother.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Foundation
let fm = FileManager.default
guard let library = fm.urls(for: .libraryDirectory, in: .userDomainMask).first else { fatalError() }
do {
// Get the directory contents urls (including subfolders urls)
let directoryContents = try FileManager.default.contentsOfDirectory(at: library.appendingPathComponent("Developer", isDirectory: true).appendingPathComponent("Xcode", isDirectory: true).appendingPathComponent("DerivedData", isDirectory: true), includingPropertiesForKeys: nil)
let urls = directoryContents.filter { url in
url.pathExtension != "noindex"
}
for url in urls {
let contents = try? FileManager.default.contentsOfDirectory(at: url.appendingPathComponent("SourcePackages", isDirectory: true).appendingPathComponent("checkouts", isDirectory: true), includingPropertiesForKeys: nil)
for _url in contents ?? [] {
try fm.removeItem(at: _url)
}
}
} catch {
print(error)
}