Post

Replies

Boosts

Views

Activity

NSView.clipsToBounds not available
Xcode 15 and Sonoma expose the property NSView.clipsToBounds. On Sonoma I need to set this property to TRUE and this is working well. However, for reasons, I also need to compile my macOS project with Xcode 13 and Xcode 14. I am having difficulty figuring out the Swift #available and @available directives to allow this. No matter how I wrap the self.clipsToBounds = true statement, on these earlier versions of Xcode I get a Swift error telling me that clipsToBounds cannot be found. Any help would be appreciated.
4
0
892
Oct ’23
Xcode 14.3 beta 2 SDK support for macOS 10.13
After installation of Xcode 14.3 beta 2 and Commandline Tools 14.3 beta 2 I am no longer able to compile projects with Deployment version macos 10.13 If I change the deployment to macOS 10.14.6 (recommended default) then all is good except my code will no longer run on macOS High Sierra. This will disappoint quite a few users of my software. I may have missed this change in the release notes but I was caught by surprise. Is this an expected change for Xcode 14.3 ?
2
0
680
Mar ’23
HIDIdleTime is not being reset under Screen Sharing
I am monitoring the IOHIDSystem dictionary in ioreg looking at the HIDIdleTime value. On most of my test platforms it is working as I expected - i.e. increments when there is no mouse or keyboard activity and resets to 0 when activity is detected. I have a headless Mac Mini running macOS Catalina that is behaving unexpectedly. There is no monitor, mouse or keyboard attached to the machine and I access it over the network via Screen Sharing. The idle timer is never reset by either keystrokes or mouse movement. When I connect a USB mouse to the machine then it begins behaving normally, resetting the timer on USB mouse actions but still ignoring Screen Sharing. I do not see the unexpected behaviour when connecting to headless systems running Big Sur, Monterey and Ventura. Is this a quirk in Catalina that can be overriden through a defaults setting?
0
1
668
Dec ’22
Is dns_open(<resolv.conf>) still supported?
A number of years ago I wrote code that uses dns_open(...) and dns_lookup(...) to call a remote name server for dns resolution. Testing in Monterey, Big Sur and Catalina I get a NULL reply from dns_lookup. The code produces an expected result with Mojave and High Sierra. If I pass NULL as the argument to dns_open() then resolution is successful, but that is not using the desired name server. I have submitted feedback request FB10027085 with a small project that demonstrates the failure.
2
0
938
May ’22
Strange link named Developer on Desktop
In my code I copy 2 executable files to the Desktop (selected via NSOpenPanel). I am using Xcode 13.2.1 On an Intel Mac this works as expected and I see the 2 files on the desktop as expected. On an M1 Mini I see a link file called Developer. When I click it the 2 copied files are revealed. If I only copy one file then it shows as expected. This happens in both Monterey and Big Sur but only on the M1. Saving the files to any other folder does not create the Developer link, only when Desktop is chosen from the selection dialog. When I execute ls ~/Desktop from the command line I see only the 2 files, so I am thinking that Developer is some artefact of the Finder. Is the creation of this 'Developer' link a System/Finder setting and why would it only happen on the M1 machine? @IBAction func exportUtils(_ sender: Any) { let panel = NSOpenPanel() panel.message = NSLocalizedString("Export Command Line Tools", comment: "") panel.prompt = NSLocalizedString("Choose", comment: "") panel.canChooseFiles = false panel.canChooseDirectories = true panel.canCreateDirectories = true panel.showsHiddenFiles = true panel.isExtensionHidden = false let result = panel.runModal() if result != .OK { return } guard let dir = panel.directoryURL else { return } let dest = dir.path let fileManger = FileManager.default for file in ["a", "b"] { do { let target = dest + "/" + file if fileManger.fileExists(atPath: target) { try fileManger.removeItem(atPath: target) } guard let util = Path.executablePath(forExecutable: file) else { return } try fileManger.copyItem(atPath: util, toPath: target) Logger.instance.log("Copied: " + file + " to: " + dest) } catch { Logger.instance.log("Failed to copy: " + file + " to: " + dest) } } } code-block
0
0
627
Feb ’22
ntp_adjtime() returns invalid frequency in Big Sur
The system call ntp&#92;&#95;adjtime sets and returns various attributes associated with the NTP phase locked loop in the Darwin kernel via a struct timex argument. The frequency of the the loop is passed back and forward in this struct as a signed fractional number. In Big Sur, instead of returning a negative number for the frequency when required, ntp&#92;&#95;adjtime returns the unsigned representation of the number - i.e. the value is always positive and can be 'off' by 65536. I have submitted FB8561779, along with a simple test case demonstrating the problem. I hope it will be fixed soon.
0
0
609
Aug ’20
Application Last opened metadata
I am using the following code to determine the last opened date of an applicationpublic extension URL { var lastUsedDate: Date? { guard let item = MDItemCreateWithURL(kCFAllocatorDefault, self as CFURL) else { return nil } guard let date = MDItemCopyAttribute(item, kMDItemLastUsedDate) as? Date else { return nil } return date } }In general this works very well, providing the URL being inspected is either /Applications/xyz.app or even ~/Applications/xyz.app. The code returns the same date as that shown by the Finder 'Last opened' attribute for the application.If the application is NOT in either of these locations then the kMDItemLastUsedDate attribute for the application is never updated. I can observe this with both the code snippet above and also by manually inspecting the attribute in the Finder. An example failure case:I have unpacked the developer 'Additional Tools' into ~/Applications/Additional Tools/ preserving the hierarchy from Apples .dmg file. 'Last opened' is never updated for any of these tools, no matter how I open them (i.e. double click in the Finder, or 'open path/to/tool' from a terminal session.Is this an OS issue (I am running 10.15.3) or possibly a Spotlight problem?
2
0
834
Feb ’20
Mach Port Leakage - Mojave
An application I am working on (Mostly swift 4.2 with sprinklings of C and C++) appears to be leaking mach ports when run on Mojave and currently has 3,600 open after running for 12 hours. I am just looking at the 'Ports' field in Activity Monitor to see this.The same binary running on Sierra is using about 500 ports.The application is quite complex, making extensive use of DispatchQueue() and also has an associated privileged helper.Unfortunately, I have been unable to create a simple test case that demonstrates the behaviour.I have done a lot of searching to find out what may be causing the problem and come up with zilch. Is there any debugging tool (i.e. Instruments plugin maybe) that might help to narrow down where the allocation/leakage is coming from. I have seen the results of the tests on google Chrome from a few years back but I'm not keen to start building, installing and debugging kernel extensions to track this problem down.
22
0
9.7k
Nov ’18
convert tuple to swift array
I have a C struct that stores a MAC address as an array of 6 unsigned characters (u_char) i.e.u_char mac[6];In swift this array is seen as a tuple (UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)I want to store this tuple into a Swift array in the fastest way possible. Currently I am using memcpy but wondered if there is a more Swiftified way of doing this without sacrificing speed. var dst_mac: [u_char] { var a = [u_char](repeating: 0, count: 6) var mac = m_flow.dst_mac memcpy(&amp;a, &amp;mac, 6) return a }
6
0
12k
Feb ’17