Post

Replies

Boosts

Views

Activity

What is changing the size of my window on first appearance?
I have some old code that a user has prodded me into trying to resolve. The issue is that the window does not size correctly on its first appearance. Stepping through my code, on initial entry to the windowDidLoad method, the size is (800, 472), which seems to correspond with the size in Interface Builder. I go and calculate the size that I want, and in one case it turns out to be (1235, 435), and I use setContentSize to get the window to the correct size. However, it is not that size when it appears, and when I get a chance to look at it, the size is (816, 435). When it runs through the same code in response to the user setting the scale, the size is correctly (1235, 435). Just to be non-deterministic, sometimes the height is 411. The numbers may change, but the difference in height is always either 0 or 24. Is there something that runs after windowDidLoad that changes the window size? Or any other clues to track down why the size changes?
3
0
524
Feb ’24
Has Sonoma got a new way to indicate a RTL keyboard layout?
A user says that a custom keyboard layout for a RTL script behaves as though it were LTR in Sonoma. In looking into it, I see that there is a new look to the Input Sources section of System Settings, with a section that only appears for RTL scripts. At a guess, this indicates that there is a new key for the Info.plist in a keyboard layout bundle, probably to be under the KLInfo_*** for the keyboard layout. These never seem to be documented, but people stumble on them occasionally. Is this another case? Has anyone seen such a key, or is there something else going on?
0
0
311
Jan ’24
Crash expanding save panel
Full crash log Running on an M1-based iMac, macOS 13.6, if I trigger a save panel, I get a crash in com.apple.appkit.xpc.openAndSavePanelService if I expand the panel with the button next to the folder selection popup button (shrinking works fine). Since this is not code that I control, what can I do? Here is the first part of the crash info: Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001a2788728 Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5 Terminating Process: exc handler [2915] Application Specific Backtrace 0: 0 CoreFoundation 0x000000019f2fb104 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000019ee19fd0 objc_exception_throw + 60 2 CoreFoundation 0x000000019f324350 _CFBundleGetValueForInfoKey + 0 3 ViewBridge 0x00000001a6cae5b0 -[NSViewServiceMarshal addChildWindow:ordered:] + 604 4 ViewBridge 0x00000001a6ca6948 -[NSWindow(ViewBridgeSwizzle) swizzledAddChildWindow:ordered:] + 92 5 AppKit 0x00000001a2e85f4c -[NSWindow(NSLayoutConstraintVisualization) _updateConstraintVisualization] + 272 6 AppKit 0x00000001a2eb3cd4 -[NSView(NSConstraintBasedLayoutInternal) engine:willBreakConstraint:dueToMutuallyExclusiveConstraints:] + 104 7 CoreAutoLayout 0x00000001a6e0ce30 -[NSISEngine handleUnsatisfiableRow:usingInfeasibilityHandlingBehavior:prospectiveRowHead:mutuallyExclusiveConstraints:] + 888```
1
0
458
Oct ’23
What is the com.apple.provenance xattr, and why can it not be removed?
I'm trying to help a user with a problem with phantom installed keyboard layouts on Ventura. It looks like the key file is ~/Library/Preferences/com.apple.inputsources.plist, which shows the extra keyboard layouts that aren't referenced anywhere else that we've been able to find. But the file has the com.apple.provenance xattr set, which cannot be removed with xattr, and the file cannot be deleted. I can't find anything that says what com.apple.provenance is for, with the only references being people saying that they don't know what it is, or another discussion on quarantine (https://developer.apple.com/forums/thread/723134) where it appears without comment. Is there anything that can be done to fix the situation?
3
1
5.4k
Jan ’23
Struggling with SMJobBless in a sandboxed app
I've got an app that is sandboxed, and it requires a privileged helper. I've worked through the EBAS sample app with various updates to conform with current systems. After a lot of work, I've got to a point where I'm stumped. The Python script SMJobBlessUtil.py returns this error, and I don't know what to do to correct it: <path to helper tool>: tool __TEXT / __info_plist section dump malformed (2) I've gone over the various settings numerous times. It doesn't fail for the EBAS sample, but does for my app. Looking at the binary, the __info_plist sections look identical apart from identifiers. This is what mine looks like (identifiers deleted): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleIdentifier</key> <string>***</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>***</string> <key>CFBundleVersion</key> <string>1.0</string> <key>SMAuthorizedClients</key> <array> <string>anchor apple generic and identifier "***" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "***")</string> </array> </dict> </plist> I must be missing something, but I've run out of ideas on where to find it. Anybody got a pointer?
21
0
5.2k
May ’22
Two document types in SwiftUI?
Documentation of DocumentGroup says: Your app can support multiple document types by adding additional document group scenes: The example has an editor and a viewer, but I need to have two editors. Creating two different DocumentGroup elements seems to work, but then there's only one New Document menu item, which targets the first DocumentGroup. Is there a way to allow the user to choose which document type to create?
2
0
1.3k
Mar ’22
How to handle undo of model properties bound to UI elements?
I have a macOS application using SwiftUI, with a ReferenceFileDocument object. I have properties that can be bound to a UI element, such as a toggle, and they change fine, but I haven't worked out how to get undo to work for these (I can do it for more complex changes when I can call into the model code and register the undo). I implemented the approach from https://lostmoa.com/blog/HandlingUndoAndRedoInSwiftUI/, and it seems to me that the undoManager keeps getting changed. If I put in a breakpoint in the onChange and print out the new undoManager, it is set when the view appears, and then set to a different value when the checkbox is clicked. So the undo gets lost and not sent to the undoManager which is in the environment from the document. I may well be missing something obvious here. Is there a way to fix this, or a better approach?
0
1
655
Sep ’21
How to make a list with a filter field in SwiftUI on Mac
I'm trying to build a dialog where the user can select from one or more of (currently) four lists. Since each list is structured similarly, I'm building a view that will be used by each of the lists. The lists can potentially have thousands of entries, so I'd like to allow the user to filter the list by typing into a search field (which in SwiftUI would be just a TextField) and only showing the matching entries. This is all working with the code below, but I can't select a row of the list. Swift struct RegistryEntry: Equatable, Identifiable, Hashable { var id = UUID() var code = "" var name = "" var other = "" } struct RegistryPicker: View { @State var sourceList: [RegistryEntry] @State var searchString = "" @State var selectedCode: String @State private var selectedItem: RegistryEntry? var body: some View { HStack() { VStack() { TextField("Filter", text: $searchString) Spacer() } List(searchString == "" ? sourceList : sourceList.filter { $0.name.localizedCaseInsensitiveContains(searchString) }, selection: $selectedItem) { entry in Text(entry.name) } } } I'm still wrapping my mind around the paradigm shift to SwiftUI, so I may well be missing something obvious. Further down the track, I need to pass the selected item up to the dialog, and preferably send an initial selection to the list. I assume that is done by making the selection a binding to the appropriate state variable in the enclosing view and setting the selection, presumably in a .onAppear clause. Any pointers there would be welcome, too!
3
0
3.3k
Mar ’21
Selection disappearing in NSTableView inside SwiftUI
I have a SwiftUI view which contains an NSTableView wrapped with an NSViewControllerRepresentable struct. This has a Coordinator, which I set up as the NSTableView's delegate. There is an implementation of tableViewSelectionDidChange to pass the selected row index up to the enclosing view. The problem is that I can click and select a row, but the selection disappears, usually on the first click, and always when clicking a column header to sort. I have looked at the various delegate methods for notifying about selection changing, and they don't seem to be called. How can I find where the selection is being changed?
4
1
1.9k
Mar ’21