Post

Replies

Boosts

Views

Activity

FileManager contentsOfDirectory fails with error 256
There is a macFUSE bug that can result in an Input/output error - https://github.com/osxfuse/osxfuse/issues/45 when listing a directory. In most cases this doesn't cause any major issues, just a "ls: mount: Input/output error" message when running ls. The problem is that the contentsOfDirectory(at:includingPropertiesForKeys:options:)  now does not work, however, the contentsOfDirectory(atPath:) method does. There appears to be a difference in how these methods handle errors, although the documentation doesn't seem to suggest this. The following code returns an array of strings without an error: FileManager.default.contentsOfDirectory(atPath: "/Users/user") The following code results in an error: FileManager.default.contentsOfDirectory(at: URL.init(fileURLWithPath:"/Users/user"), includingPropertiesForKeys: nil) REPL: $E3: NSError = domain: "NSCocoaErrorDomain" - code: 256 { _userInfo = 3 key/value pairs { [0] = { key = "NSURL" value = "file:///Users/user/mount" } [1] = { key = "NSFilePath" value = "/Users/user/mount" } [2] = { key = "NSUnderlyingError" value = } } } Xcode: Error Domain=NSCocoaErrorDomain Code=256 "The file “mount” couldn’t be opened." UserInfo={NSURL=file:///Users/user/mount, NSFilePath=/Users/user/mount, NSUnderlyingError=0x600000289740 {Error Domain=NSPOSIXErrorDomain Code=5 "Input/output error”}} Passing [] as the includingPropertiesForKeys value gives the same result. It's also interesting that in the REPL the NSUnderlyingError value is missing.
6
0
2.2k
Apr ’21
Simulators fail to download in Xcode
Recently simulators have not been able to be downloaded from Xcode, after endlessly trying the transfer rate was well below 100kb/s and would fail after a short while. The speed was on average 100x slower than other servers with the exception of a short spike of passable speeds. Because Xcode for some reason doesn't support resuming simulator downloads, I downloaded the simulators directly from the dvtdownloadableindex file using two different methods but the fileSize values consistently differed slightly from the downloaded files. This resulted in a Missing Signature error when adding the simulator with xcrun simctl runtime add.
1
0
1.4k
Dec ’22
HTML NSAttributedString technique that avoids Sonoma's TextKit issues
Basic HTML strings do not display correctly on macOS Sonoma, I am wondering if there is an alternative technique that can be utilized. There was a minor change in macOS 14.2, which fixed some cases but made others much worse. Consider the following code: override func viewDidLoad() { super.viewDidLoad() let html = """ <table width="100%" border="1" style="color: white"> <tr> <td align="left">Left</td> <td align="right">Right</td> </tr> </table> """ let data = Data(html.utf8) let definition = try! NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: NSNumber(value: String.Encoding.utf8.rawValue)], documentAttributes: nil) let frameRect = NSRect(x: 100, y: 0, width: 300, height: 200) let textView = NSTextView(frame: frameRect) textView.textStorage?.setAttributedString(definition) textView.backgroundColor = .clear view.addSubview(textView) } On macOS 14 (23A5312d) it looks like this (FB13170237): On macOS 14.2 (23C64) it looks like this (FB13465833):
1
0
845
Dec ’23