My code is crashing Xcode (or even macOS kernel) during debugging - Xcode just vanishes from screen!
// pseudo code
public func hunt(in directory: URL) {
let fileIterator = fileMan.enumerator(at: directory)
// collect app packages into a list
var packages = [URL]()
for case let fileURL as URL in fileIterator {
if fileURL.pathExtension == "app" { packages.append(fileURL) }
}
// FileWrappers
var wrappers = [FileWrappers]()
for packageURL in packages {
//!!! The line below eventually crashes Xcode (or even macOS kernel once)!
wrappers[packageURL] = try? FileWrapper(url: packageURL, options: .immediate)
// NOTE: I need FileWrapper.matchesContents later in some code
}
}
// unit test case
func test() {}
myObj.hunt(in: URL(fileURLWithPath: "/Applications"))
}
I suspect that the FileWrapper constructor is traversing directories and encounter cyclic symbolic links and eventually it crashes; since it's running at system runtime level, most probably it also crashes macOS kernel!
So my question is that is there any way to detect cyclic symbolic links so that I can design my own logics similar to FileWrapper?