ulimit -n
gives 256 on my computer, and I indeed see hitting that limit in the UI macOS app (correctly fails with "Fatal error: failed to open 252th file", see below)... Although this doesn't happen in the console app! Why?!
The test code:
func test() {
let files = (0 ..< 1000).map { i in
let path = URL.temporaryDirectory.appendingPathComponent(UUID().uuidString)
let file = open(path.path, O_CREAT)
if file < 0 {
fatalError("failed to open \(i)th file")
}
return file
}
print("opened \(files.count) files")
}
test() // or call it from, say, ContentView's init of the UI app.