Post

Replies

Boosts

Views

Activity

Invalid argument error from tcsetattr when setting speed to anything other than predefined
I'm trying to communicate with an RS-485 device using a USB-to-RS-485 adapter based on a CP21012N. It's capable of speeds up to 3 Mbaud. However, when I call tcsetattr() with speed set to anything other than one of the predefined constants (using cfsetspeed()), I get an "Invalid argument" error back from the call. Googling, I found https://github.com/avrdudes/avrdude/issues/771 Seems like macOS really can't accept baud rates outside the predefined set without resorting to ioctl?
5
0
1k
Jun ’24
Changing the title in the toolbar of a SwiftData/UI document app?
I just started a little macOS app using SwiftUI and SwiftData. It seems to insist on placing the name of the file (along with the extension) in the title bar. I would prefer to put the name of the selection there instead (i.e. instead of "Untitled.paper", "New Article").. Along with that, I'd like to control the appearance of "Edited" as well. I have the suspicion that this simply isn't possible.
0
0
513
Mar ’24
Simulating cross-device passkey sign in?
It seems cross-device passkey authentication isn't supported by the Simulator, is that right? I can't tell if it's the simulator not supporting it, or my app/server failing. My app, running in the Simulator, presents a QR code during sign-in flow. I scan that with my phone, and it just spins "connecting…". Can anyone confirm that the Simulator just doesn't support this? What are my options for testing this flow? I guess I need another device not sign in to my AppleID.
1
0
1k
Mar ’24
Xcode 15 "Missing package product" error when using local package path instead of url
I've got this SwiftPM project. It has a dependency that I needed to edit, so I forked it on github and checked it out locally. Then I referenced the local repo in the Package.swift file with package(path:) instead of package(url:). This caused it to report Package.swift: error: Missing package product 'WebAuthn' (in target 'App' from project 'server') I had to commit my changes, and re-reference the repo, to get it to see my updates. This problem has been around for some time, but seems to be related to how the path name differs from the built target name (it works fine in another project i have where the package directory and target have the same name). I've submitted FB13677717 about it, but is there a workaround?
0
1
2.7k
Mar ’24
Determining if user has passkey for service already?
I'm working my way through adding passkey support to my app. At app launch, I'd like to test to see if the user has already created a passkey for the service, and if not, immediately present the account creation UI. Is there an API call I can make to see if the user already has a credential? From the examples I’ve found, it seems I should just try to sign in, and I’ll get an error callback if there are no stored credentials. Is that right?
4
0
2k
Mar ’24
System logging messages disappear after about 90 seconds
I'm having an issue with logging on my system (Sonoma 14.3.1), in that log messages disappear after 60-90 seconds, despite logging being configured to persist. This seems to happen across all subsystems. The symptoms are: • Watching the log stream in Console.app, messages older than 60-90 seconds disappear, even if no new messages are coming in. • log show --last 2d only returns messages from the last couple of minutes. I've filed FB13616761, but wondered if anyone had any other insights or suggestions. TIA
0
0
711
Feb ’24
Does StoreKit2 not reliably report available purchases shortly after login?
My app is a login item that gets registered as a background agent using SMAppService. On launch it checks to see that the user has an active subscription, and when I run it from Xcode, this works fine. But it seems that if I restart my machine and it is run from launchd right at login, StoreKit doesn't return any purchases. This results in my app throwing up a window to tell the user to subscribe. It’s hard to be sure this is the behavior, because I can't really use a debugger, and for whatever reason, OSLog is not persisting messages (despite being configured to do so). Does anyone know if it takes a while after restart or login for Store Kit to reliably return purchases?
1
0
592
Feb ’24
SpatialTap on NO entity?
How do I respond to a SpatialTapGesture in my RealityView when the tap is on no entity whatsoever? I tried just doing RealityView {} .gesture(SpatialTapGesture().onEnded { print("foo") }) but that doesn't get called. All I can find searching is advice to add Collision and Input components to entities, but I don't want this on an entity; I want it when the user is not looking at any specific entity.
0
0
490
Feb ’24
SMAppService.agent.register() will launch a second instance of an application
Because I can't find a way to share StoreKit purchases between two apps (macOS), I was forced to make my LSUIElement application a single app. This is turning out to work reasonably well, except for one issue that I hadn't noticed before (maybe it's new in 14.2?). The normal flow is this: User double-clicks app icon App calls SMAppService.agent(plistName: "com.myagent.plist").register(). The referenced plist points to the same application binary (see attached project) that the user launched in step 1. System launches a second instance of the application binary What I want the call to do instead is see that the app is already running, and just adopt it (that is, if it is killed or crashes, relaunch it). I see two inelegant workarounds: Wait until the user is done configuring the app after first launch, register the app and then quit. Thing is, I can't be sure when they're done, e.g. if they don't close the window. Allow both instances of the app to run, but quit if they close the window and it wasn't launched by launchd, or if there are other instances running. This feels fragile (e.g. if the behavior of register() is ever improved as I'd like). The best solution, of course, would be to share StoreKit context between apps, so I could separate this into the UI app and background agent. (To Apple: I've filed FB13574819 with my project attached.)
0
0
630
Feb ’24
Xcode commit color meaning?
In the abominable new commit line diff view, I have no idea what the colors mean. Some text is highlighted in a cream color, other text in purple. Googling just turns up people hating the view, as I do. I haven't found anything in the Xcode docs that explains the coloring. Looking at my files, I think cream is a deleted line and purple is added lines. Is that right? Light mode.
1
0
883
Jan ’24
Determining if Accessibility (for CGEventTap) access was revoked?
My app depends on the user granting Accessibility access (Allow this application to control your computer). There’s no formal permissions API (that I know of) for this, it just happens implicitly when I use the API for the first time. I get an error if the user hasn’t granted permission. If the user grants permission and I'm able to successfully register my CGEventTap (a modifier key event tap), but then later revokes it, key responsiveness goes awry. I don’t get any kind of error to my callback, but I do get tapDisabledByTimeout events periodically. I believe something is causing significant delays (but not preventing) in delivering events to my tap. Upon receiving this, I'm considering attempting to register another tap as a way to test permission, and disabling the real one if I no longer have permission. Does anyone have any better ideas? For Apple: see FB13533901.
2
0
1.1k
Jan ’24
Can't change store kit renewal rate, stuck at every two seconds
I wrote a StoreKit unit test and set the renewal rate to .oneRenewalEveryTwoSeconds for the test session. But now my App expires and renews every two seconds when running normally, even though the StoreKit Configuration file is set to "Real Time." Changing it to anything else doesn't change the renewal rate. I've tried cleaning the build folder. If, however, I set my SKTestSession explicitly to .realTime and run the test again, then my app behaves. However, again, it doesn't matter what I set the Configuration Settings to. Anyone know where this information is stored?
0
0
657
Jan ’24
configd is locking up my machine constantly and spamming logs
I've filed FB13497581 on this topic. But Ever since macOS 14 (or perhaps one of the releases that came after), my machine (M1 MacBook Pro) frequently locks up the UI. Sometimes it's so bad the mouse won't move. It only lasts a few seconds, but at its worst it happens every few seconds. It usually manifests as no text appearing as I type (which sucks, since I write code all day). I'm fairly certain configd is to blame. When this occurs, configd is using nearly 100% CPU, and spams logs with thousands of messages per second. Killing it does nothing. Rebooting might fix it for a bit, but it eventually comes back. I'm wondering if there’s some on-disk state I can blow away to start SystemConfiguration from scratch. I hate to do that in case someone from Apple asks me for files to analyze, but I feel like my FB is just going to languish. Meanwhile, this is rendering my machine unusable. Or if anyone knows how to interpret the log messages.
0
0
523
Jan ’24
How can I detect if my SwiftUI Window has been closed?
My macOS SwiftUI app has a single Window scene. .onAppear() is called when it is created, but if it is closed, .onDisappear() is not called. How can I detect when the window is closed? Note, I need to distinguish between closed and inactive or background. scenePhase is not updated for the window or any of its subviews when the window is deactivated. controlPhase is, however. Note that my app delegate implements: func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return false }
0
0
878
Dec ’23