Posts

Post not yet marked as solved
3 Replies
243 Views
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?
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
21 Replies
4.2k Views
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?
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
0 Replies
205 Views
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?
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
0 Replies
265 Views
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```
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
3 Replies
3.6k Views
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?
Posted
by Mussau.
Last updated
.
Post marked as solved
4 Replies
1.6k Views
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?
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
2 Replies
976 Views
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?
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
0 Replies
569 Views
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?
Posted
by Mussau.
Last updated
.
Post marked as solved
3 Replies
2.5k Views
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!
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
1 Replies
910 Views
My app uses a helper application to move files around in the file system, and it's invoked via an AppleScript which is constructed on the fly as:do shell script "(helper path) (source) (destination)" with with administrator privilegesEach of the arguments is done with "quoted form of" to ensure that there are no surprises with malformed names.The helper application is a dead simple Swift command-line tool:import Foundation let argumentCount = CommandLine.argc let argumentList = CommandLine.arguments assert(argumentCount == 3, "Usage: \(argumentList[0]) <source file> <destination folder>") let sourcePath = argumentList[1] let sourceURL = URL.init(fileURLWithPath: sourcePath) let destinationPath = argumentList[2] let destinationURL = URL.init(fileURLWithPath: destinationPath) let fileManager = FileManager.default do { try fileManager.moveItem(at: sourceURL, to: destinationURL) } catch { // Don't worry about errors at this point }The problem is that, in Catalina but not in earlier systems, this fails if the destination is a protected folder (in this particular case, it will always be /Library/Keyboard Layouts). I get an error message that I don't have permission (if I put something into the catch block to see it). I can do the file move in the Finder by authenticating, so it should be possible. It looks as though the helper isn't getting the administrator privileges that I've given it.Am I diagnosing it correctly? Can something be done about it? I'd adopted this solution to get around the need to have a privileged helper that I had in the past, so it would be unfortunate if this can no longer be done.John
Posted
by Mussau.
Last updated
.
Post marked as solved
2 Replies
798 Views
I am getting ready to release a notarized version of my app. It supports back to Mavericks (10.9), so I would like to have two versions of a tool, a 32-bit version that works on the older systems, and a 64-bit one that works on more recent systems. I would use whichever tool is appropriate based on the runtime environment.But this brings me to the question: can I successfully notarize an app which has a 32-bit tool in its bundle? I haven't been able to find an answer to that question so far.Thanks for any pointers!John
Posted
by Mussau.
Last updated
.
Post marked as solved
1 Replies
2.5k Views
I'm working on a rewrite of my app in Swift from an older mixed C/C++/Objective-C version, and I'm getting a crash when trying to create a drag image from an NSTextView. I have a custom view containing an NSTextView which is set up like this:let textView = NSTextView(frame: textRect) textView.drawsBackground = false textView.isEditable = false textView.isSelectable = false textView.isVerticallyResizable = false textView.isHorizontallyResizable = false textView.selectedTextAttributes = [:] addSubview(textView)(I have tried isSelectable true and false, without change of behaviour). In the mouseDragged(with:) function, I have this code:textView.setSelectedRange(NSMakeRange(0, textView.textStorage!.length)) let dragImage = textView.dragImageForSelection(with: event, origin: nil) let dragItem = NSDraggingItem(pasteboardWriter: self) dragItem.setDraggingFrame(NSMakeRect(0.0, 0.0, theRect.size.width, theRect.size.height), contents: dragImage) beginDraggingSession(with: [dragItem], event: event, source: self)I always get a crash in the call to dragImageForSelection(with:origin:):2019-04-29 09:16:38.291806+0300 MyApp[61986:7244166] [General] Cannot lock focus on image <NSImage 0x6000018c4a80 Size={0, 0} Reps=() flipped:YES (flippedness is deprecated)>, because it is size zero.2019-04-29 09:16:38.293248+0300 Ukelele Swift[61986:7244166] [General] ( 0 CoreFoundation 0x00007fff3f3b5cf9 __exceptionPreprocess + 256 1 libobjc.A.dylib 0x00007fff69f4aa17 objc_exception_throw + 48 2 CoreFoundation 0x00007fff3f3b5b2b +[NSException raise:format:] + 201 3 AppKit 0x00007fff3caa9f17 -[NSImage _lockFocusOnRepresentation:rect:context:hints:flipped:] + 316 4 AppKit 0x00007fff3caa9dd1 __51-[NSImage lockFocusWithRect:context:hints:flipped:]_block_invoke + 68 5 AppKit 0x00007fff3ca3aa7b -[NSImage _usingBestRepresentationForRect:context:hints:body:] + 156 6 AppKit 0x00007fff3caa9d83 -[NSImage lockFocusWithRect:context:hints:flipped:] + 141 7 AppKit 0x00007fff3cbabfe5 -[NSImage lockFocusFlipped:] + 111 8 AppKit 0x00007fff3d1dfcdb -[NSTextView(NSDragging) dragImageForSelectionWithEvent:origin:] + 843 9 MyApp 0x000000010022070a $s13MyApp10MyViewC12mouseDragged4withySo7NSEventC_tF + 842 10 MyApp 0x0000000100220b2c $s13MyApp10MyViewC12mouseDragged4withySo7NSEventC_tFTo + 60 11 AppKit 0x00007fff3caf2b9f -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6840 12 AppKit 0x00007fff3caf0e9f -[NSWindow(NSEventRouting) sendEvent:] + 478 13 AppKit 0x00007fff3c9906c3 -[NSApplication(NSEvent) sendEvent:] + 331 14 AppKit 0x00007fff3c97eee8 -[NSApplication run] + 755 15 AppKit 0x00007fff3c96e3f0 NSApplicationMain + 777 16 MyApp 0x00000001001a94dd main + 13 17 libdyld.dylib 0x00007fff6b7783d5 start + 1 18 ??? 0x0000000000000003 0x0 + 3)The Objective-C version is practically identical, and does not crash:NSDraggingItem *dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:self]; [self.textView setSelectedRange:NSMakeRange(0, [self.textView.textStorage length])]; NSImage *dragImage = [self.textView dragImageForSelectionWithEvent:theEvent origin:nil]; [dragItem setDraggingFrame:NSMakeRect(0.0, 0.0, theRect.size.width, theRect.size.height) contents:dragImage]; NSArray *dragItems = [NSArray arrayWithObject:dragItem]; [self beginDraggingSessionWithItems:dragItems event:theEvent source:self];I've checked the NSTextView and it is correct, the selection is being set correctly, but the crash happens in the Swift version.Has anybody got a clue how to fix this?Thanks,John
Posted
by Mussau.
Last updated
.