Post

Replies

Boosts

Views

Activity

Reply to Weird crashes when accessing Swift Array
Thanks, I just tried that. Then I realized that I can barely see any of my app's symbol names in the disassembly (which I created with otool -vt /path/to/executable). For instance I cannot find any of the method names mentioned in the crash reports. The disassembly looks like this: ~/Library/Developer/Xcode/Archives/2024-07-12/MyApp macOS 12.07.2024, 20.43.xcarchive/Products/Applications/MyApp.app/Contents/MacOS/MyApp (architecture arm64): (__TEXT,__text) section 0000000100004a00 stp x20, x19, [sp, #-0x20]! 0000000100004a04 stp x29, x30, [sp, #0x10] 0000000100004a08 add x29, sp, #0x10 0000000100004a0c adrp x8, 567 ; 0x10023b000 0000000100004a10 ldr x0, [x8, #0xc30] ; Objc class ref: bad class ref 0000000100004a14 bl 0x1001d664c ; symbol stub for: _objc_opt_self 0000000100004a18 adrp x8, 567 ; 0x10023b000 0000000100004a1c ldr x1, [x8, #0x588] ; Objc selector ref: sharedApplication 0000000100004a20 bl 0x1001d6634 ; Objc message: -[x0 sharedApplication] 0000000100004a24 mov x29, x29 0000000100004a28 bl 0x1001d667c ; symbol stub for: _objc_retainAutoreleasedReturnValue 0000000100004a2c adrp x19, 587 ; 0x10024f000 0000000100004a30 str x0, [x19, #0xb30] 0000000100004a34 mov x0, #0x0 0000000100004a38 bl 0x1000e6c04 0000000100004a3c bl 0x1001d6604 ; symbol stub for: _objc_allocWithZone ... When you wrote disassemble the code pointed to be the backtrace to make sure it’s the thunk that you expect it to be were you thinking of a particular command that creates disassemblies with symbol names, or how would you "make sure it's the thunk that you expect it to be"?
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’24
Reply to Weird crashes when accessing Swift Array
[quote='796605022, DTS Engineer, /thread/760029?answerId=796605022#796605022'] I usually investigate issues like this at the assembly level [/quote] Thanks. I never did this before and I wasn't able to find anything helpful on the internet. otool can disassemble, but of course the addresses are different than those in the crash report. Is there a way to easily map the addresses, or are there better Terminal tools for this?
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’24
Reply to Weird crashes when accessing Swift Array
[quote='796453022, DTS Engineer, /thread/760029?answerId=796453022#796453022'] This shows how the ns as! [MyElement] cast is done lazily [/quote] Thanks, this already helped me reproduce and fix the second crash. The array was coming from a token field's objectValue. Regarding the first crash, I noticed something strange. The crash report seems to imply that a particular method called another one, which is impossible. Let me show and explain to you the rest of the stacktrace: ... Code Type: ARM-64 Parent Process: launchd [1] User ID: 501 Date/Time: 2024-07-18 14:59:40.4375 +0800 OS Version: macOS 15.0 (24A5289h) ... Crashed Thread: 0 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001045048b8 Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5 Terminating Process: exc handler [1771] Thread 0 Crashed: 0 MyApp 0x00000001045048b8 specialized Collection.map<A>(_:) + 596 1 MyApp 0x00000001045011e4 MyViewController.validateToolbarButtons() + 648 (MyViewController.swift:742) ... 12 MyApp 0x00000001044fcef4 MyViewController.myOtherAction(_:) + 184 (MyViewController.swift:455) 13 MyApp 0x00000001044fff28 @objc MyViewController.myModalAction(_:) + 80 14 AppKit 0x000000019e2ae13c -[NSApplication(NSResponder) sendAction:to:from:] + 460 15 AppKit 0x000000019e375b08 -[NSMenuItem _corePerformAction] + 372 16 AppKit 0x000000019ea4be30 _NSMenuPerformActionWithHighlighting + 152 17 AppKit 0x000000019e3ad5d0 -[NSMenu performActionForItemAtIndex:] + 200 18 AppKit 0x000000019e3ad4f0 -[NSMenu _internalPerformActionForItemAtIndex:] + 76 19 AppKit 0x000000019ea4204c +[NSCocoaMenuImpl _performActionForMenuItem:] + 176 20 AppKit 0x000000019e84ff58 -[NSMenuTrackingSession _performPostTrackingDismissalActions] + 268 21 AppKit 0x000000019e84fc60 -[NSMenuTrackingSession startRunningMenuEventLoop:] + 1332 22 AppKit 0x000000019e84f6d0 -[NSMenuTrackingSession startMonitoringEvents:] + 256 23 AppKit 0x000000019efe5d78 -[NSContextMenuTrackingSession startMonitoringEvents:] + 144 24 AppKit 0x000000019e8048f8 +[NSContextMenuImpl presentPopup:fromView:withContext:animated:] + 848 25 AppKit 0x000000019ea4d5ec _NSPopUpMenu + 2128 26 AppKit 0x000000019ea51cbc -[NSCocoaMenuImpl _popUpContextMenu:withEvent:forView:withFont:] + 304 27 AppKit 0x000000019e429acc -[NSMenu _popUpContextMenu:withEvent:forView:withFont:] + 208 28 AppKit 0x000000019ece4658 -[NSView _showMenuForEvent:] + 72 29 AppKit 0x000000019e425ff4 -[NSView rightMouseDown:] + 76 30 AppKit 0x000000019e7225e0 -[NSControl _rightMouseUpOrDown:] + 352 31 AppKit 0x000000019ed81ec4 _routeRightMouseDownEvent + 264 32 AppKit 0x000000019e2348f8 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 420 33 AppKit 0x000000019e234584 -[NSWindow(NSEventRouting) sendEvent:] + 284 34 AppKit 0x000000019ea1f568 -[NSApplication(NSEventRouting) sendEvent:] + 1656 35 AppKit 0x000000019e632b78 -[NSApplication _handleEvent:] + 60 36 AppKit 0x000000019e100914 -[NSApplication run] + 520 37 AppKit 0x000000019e0d7094 NSApplicationMain + 888 38 MyApp 0x000000010446ca80 main + 128 (main.swift:12) 39 dyld 0x000000019a16b274 start + 2840 The ellipsis only hides methods from my own classes. Directly below it, it would seem that @objc MyViewController.myModalAction(_:), which shows an app modal window, somehow calls MyViewController.myOtherAction(_:), but myOtherAction can only be called by a menu or the press of a toolbar button which are both disabled by the modal window shown by myModalAction. Does this mean that myOtherAction is called somehow when the modal window opened by myModalAction is closed? Another interesting point: I don't know why myModalAction is prefixed with @objc, since both are declared as @IBAction func methodName(_ sender: Any). The only difference is that myModalAction is set as a table view's doubleAction, but from the rest of the stacktrace it seems like myModalAction is called by a menu.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’24
Reply to How to link multiple text views to a single text storage in TextKit 2
Thanks. The part I was missing is the one the documentation for NSTextContentManager doesn't mention, which is that it is an abstract class whose (apparently) only concrete subclass is NSTextContentStorage, which has a textStorage property. guard let textStorage: NSTextStorage = (textLayoutManager?.textContentManager as? NSTextContentStorage)?.textStorage else { return } The sample code also changes the textStorage inside the block passed to textContentManager.performEditingTransaction(_:), which the documentation doesn't seem to explain why it's necessary.
Topic: App & System Services SubTopic: General Tags:
Jun ’24
Reply to Getting inode number from URL
I just wanted to add that for some reason the order of imports inside the test files is important in some cases. I have to write: @testable import MyApp import XCTest Inverting those two lines causes several compiler errors inside the bridging header file: Redefinition of 'vtype' Redefinition of enumerator 'VBAD' Redefinition of enumerator 'VBLK' ... I have no idea why this happens, as in another project with the exact same bridging header file the order of imports seems to be irrelevant and doesn't cause any compiler errors.
Topic: App & System Services SubTopic: General Tags:
Jun ’24
Reply to NSTableView - How can the background color of the row views be changed dynamically?
NSTableRowView has a property backgroundColor, but this is also used by AppKit when you set tableView.usesAlternatingRowBackgroundColors = true. The only way I could make it work was by returning a custom row view subclass and dynamically returning a custom background color. class MyRowView: NSTableRowView { var myBackgroundColor: NSColor? override var backgroundColor: NSColor { get { return myBackgroundColor ?? super.backgroundColor } set { super.backgroundColor = newValue } } } and in the delegate func outlineView(_ outlineView: NSOutlineView, didAdd rowView: NSTableRowView, forRow row: Int) { if myCondition { (rowView as! MyRowView).myBackgroundColor = myColor } }
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’24
Reply to Share settings from SwiftUI in-app settings view to other views
I have more than 10 variables, of different types. Your suggestion of multiplexing doesn't work in this case. I have something like this, where I want to bind ContentView.var1 to SettingsView.var1, for each of the var listed in SettingsView, and possibly to other views as well. struct ContentView: View { var body: some View { VStack { if var1 { Text("Text") } } SettingsView() } } struct SettingsView: View { @AppStorage("var1") private var var1 = false @AppStorage("var2") private var var2 = true @AppStorage("var3") private var var3 = false @AppStorage("var4") private var var4 = MyType.Nested.value @AppStorage("var5") private var var5: Double? @AppStorage("var6") private var var6 = 0.0 @AppStorage("var7") private var var7 = 0.0 @AppStorage("var8") private var var8: String? @AppStorage("var9") private var var9: Data? @AppStorage("var10") private var var10 = true @AppStorage("var11") private var var11 = 0 var body: some View { Toggle("Var 1", isOn: $var1) ... } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to NSProgressIndicator bindings don't do anything
But according to Progress documentation:: Each of the properties of a progress object, including totalUnitCount, completedUnitCount, and fractionCompleted, support key-value observing (KVO). This makes it extremely easy for a view or window controller object to observe the properties, and update UI elements, such as progress indicators, when the values change.
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’24
Reply to iPad Pro 13" screenshots for the App Store
The App Store Connect API documentation still doesn't list the new iPads: https://developer.apple.com/documentation/appstoreconnectapi/screenshotdisplaytype When adding screenshots to 13" iPads on the website, they still seem to use the display type APP_IPAD_PRO_3GEN_129 when listed by the API, and uploading to that same type uploads them to the 13" display type instead, and then there is the requirement that one still has to upload screenshots for 12.9" display type, without an apparent way of doing so. I would expect to have an option to upload to 13" display type that is also used for 12.9" display type as well.
May ’24
Reply to Weird crashes when accessing Swift Array
Thanks, I just tried that. Then I realized that I can barely see any of my app's symbol names in the disassembly (which I created with otool -vt /path/to/executable). For instance I cannot find any of the method names mentioned in the crash reports. The disassembly looks like this: ~/Library/Developer/Xcode/Archives/2024-07-12/MyApp macOS 12.07.2024, 20.43.xcarchive/Products/Applications/MyApp.app/Contents/MacOS/MyApp (architecture arm64): (__TEXT,__text) section 0000000100004a00 stp x20, x19, [sp, #-0x20]! 0000000100004a04 stp x29, x30, [sp, #0x10] 0000000100004a08 add x29, sp, #0x10 0000000100004a0c adrp x8, 567 ; 0x10023b000 0000000100004a10 ldr x0, [x8, #0xc30] ; Objc class ref: bad class ref 0000000100004a14 bl 0x1001d664c ; symbol stub for: _objc_opt_self 0000000100004a18 adrp x8, 567 ; 0x10023b000 0000000100004a1c ldr x1, [x8, #0x588] ; Objc selector ref: sharedApplication 0000000100004a20 bl 0x1001d6634 ; Objc message: -[x0 sharedApplication] 0000000100004a24 mov x29, x29 0000000100004a28 bl 0x1001d667c ; symbol stub for: _objc_retainAutoreleasedReturnValue 0000000100004a2c adrp x19, 587 ; 0x10024f000 0000000100004a30 str x0, [x19, #0xb30] 0000000100004a34 mov x0, #0x0 0000000100004a38 bl 0x1000e6c04 0000000100004a3c bl 0x1001d6604 ; symbol stub for: _objc_allocWithZone ... When you wrote disassemble the code pointed to be the backtrace to make sure it’s the thunk that you expect it to be were you thinking of a particular command that creates disassemblies with symbol names, or how would you "make sure it's the thunk that you expect it to be"?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to Read and write file tags with URLResourecKey.tagNamesKey on iOS
I opened FB13712968 back in April, but didn't get any response so far. I know this is a weird why question, but I thought maybe there's a known reason I'm ignoring.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to Weird crashes when accessing Swift Array
[quote='796605022, DTS Engineer, /thread/760029?answerId=796605022#796605022'] I usually investigate issues like this at the assembly level [/quote] Thanks. I never did this before and I wasn't able to find anything helpful on the internet. otool can disassemble, but of course the addresses are different than those in the crash report. Is there a way to easily map the addresses, or are there better Terminal tools for this?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to Weird crashes when accessing Swift Array
[quote='796453022, DTS Engineer, /thread/760029?answerId=796453022#796453022'] This shows how the ns as! [MyElement] cast is done lazily [/quote] Thanks, this already helped me reproduce and fix the second crash. The array was coming from a token field's objectValue. Regarding the first crash, I noticed something strange. The crash report seems to imply that a particular method called another one, which is impossible. Let me show and explain to you the rest of the stacktrace: ... Code Type: ARM-64 Parent Process: launchd [1] User ID: 501 Date/Time: 2024-07-18 14:59:40.4375 +0800 OS Version: macOS 15.0 (24A5289h) ... Crashed Thread: 0 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001045048b8 Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5 Terminating Process: exc handler [1771] Thread 0 Crashed: 0 MyApp 0x00000001045048b8 specialized Collection.map<A>(_:) + 596 1 MyApp 0x00000001045011e4 MyViewController.validateToolbarButtons() + 648 (MyViewController.swift:742) ... 12 MyApp 0x00000001044fcef4 MyViewController.myOtherAction(_:) + 184 (MyViewController.swift:455) 13 MyApp 0x00000001044fff28 @objc MyViewController.myModalAction(_:) + 80 14 AppKit 0x000000019e2ae13c -[NSApplication(NSResponder) sendAction:to:from:] + 460 15 AppKit 0x000000019e375b08 -[NSMenuItem _corePerformAction] + 372 16 AppKit 0x000000019ea4be30 _NSMenuPerformActionWithHighlighting + 152 17 AppKit 0x000000019e3ad5d0 -[NSMenu performActionForItemAtIndex:] + 200 18 AppKit 0x000000019e3ad4f0 -[NSMenu _internalPerformActionForItemAtIndex:] + 76 19 AppKit 0x000000019ea4204c +[NSCocoaMenuImpl _performActionForMenuItem:] + 176 20 AppKit 0x000000019e84ff58 -[NSMenuTrackingSession _performPostTrackingDismissalActions] + 268 21 AppKit 0x000000019e84fc60 -[NSMenuTrackingSession startRunningMenuEventLoop:] + 1332 22 AppKit 0x000000019e84f6d0 -[NSMenuTrackingSession startMonitoringEvents:] + 256 23 AppKit 0x000000019efe5d78 -[NSContextMenuTrackingSession startMonitoringEvents:] + 144 24 AppKit 0x000000019e8048f8 +[NSContextMenuImpl presentPopup:fromView:withContext:animated:] + 848 25 AppKit 0x000000019ea4d5ec _NSPopUpMenu + 2128 26 AppKit 0x000000019ea51cbc -[NSCocoaMenuImpl _popUpContextMenu:withEvent:forView:withFont:] + 304 27 AppKit 0x000000019e429acc -[NSMenu _popUpContextMenu:withEvent:forView:withFont:] + 208 28 AppKit 0x000000019ece4658 -[NSView _showMenuForEvent:] + 72 29 AppKit 0x000000019e425ff4 -[NSView rightMouseDown:] + 76 30 AppKit 0x000000019e7225e0 -[NSControl _rightMouseUpOrDown:] + 352 31 AppKit 0x000000019ed81ec4 _routeRightMouseDownEvent + 264 32 AppKit 0x000000019e2348f8 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 420 33 AppKit 0x000000019e234584 -[NSWindow(NSEventRouting) sendEvent:] + 284 34 AppKit 0x000000019ea1f568 -[NSApplication(NSEventRouting) sendEvent:] + 1656 35 AppKit 0x000000019e632b78 -[NSApplication _handleEvent:] + 60 36 AppKit 0x000000019e100914 -[NSApplication run] + 520 37 AppKit 0x000000019e0d7094 NSApplicationMain + 888 38 MyApp 0x000000010446ca80 main + 128 (main.swift:12) 39 dyld 0x000000019a16b274 start + 2840 The ellipsis only hides methods from my own classes. Directly below it, it would seem that @objc MyViewController.myModalAction(_:), which shows an app modal window, somehow calls MyViewController.myOtherAction(_:), but myOtherAction can only be called by a menu or the press of a toolbar button which are both disabled by the modal window shown by myModalAction. Does this mean that myOtherAction is called somehow when the modal window opened by myModalAction is closed? Another interesting point: I don't know why myModalAction is prefixed with @objc, since both are declared as @IBAction func methodName(_ sender: Any). The only difference is that myModalAction is set as a table view's doubleAction, but from the rest of the stacktrace it seems like myModalAction is called by a menu.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to How to link multiple text views to a single text storage in TextKit 2
Thanks. The part I was missing is the one the documentation for NSTextContentManager doesn't mention, which is that it is an abstract class whose (apparently) only concrete subclass is NSTextContentStorage, which has a textStorage property. guard let textStorage: NSTextStorage = (textLayoutManager?.textContentManager as? NSTextContentStorage)?.textStorage else { return } The sample code also changes the textStorage inside the block passed to textContentManager.performEditingTransaction(_:), which the documentation doesn't seem to explain why it's necessary.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Getting inode number from URL
I just wanted to add that for some reason the order of imports inside the test files is important in some cases. I have to write: @testable import MyApp import XCTest Inverting those two lines causes several compiler errors inside the bridging header file: Redefinition of 'vtype' Redefinition of enumerator 'VBAD' Redefinition of enumerator 'VBLK' ... I have no idea why this happens, as in another project with the exact same bridging header file the order of imports seems to be irrelevant and doesn't cause any compiler errors.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to UNUserNotificationCenter crash
Did you find a solution? I'm having the same issue on macOS 10.14.
Replies
Boosts
Views
Activity
Jun ’24
Reply to NSTableView - How can the background color of the row views be changed dynamically?
NSTableRowView has a property backgroundColor, but this is also used by AppKit when you set tableView.usesAlternatingRowBackgroundColors = true. The only way I could make it work was by returning a custom row view subclass and dynamically returning a custom background color. class MyRowView: NSTableRowView { var myBackgroundColor: NSColor? override var backgroundColor: NSColor { get { return myBackgroundColor ?? super.backgroundColor } set { super.backgroundColor = newValue } } } and in the delegate func outlineView(_ outlineView: NSOutlineView, didAdd rowView: NSTableRowView, forRow row: Int) { if myCondition { (rowView as! MyRowView).myBackgroundColor = myColor } }
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Crash in AVPlayerView.setPlaybackControlsViewController
I opened FB13907122. I will ask the customer if they are able to share a sysdiagnose with me when they get back to me.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Share settings from SwiftUI in-app settings view to other views
I have more than 10 variables, of different types. Your suggestion of multiplexing doesn't work in this case. I have something like this, where I want to bind ContentView.var1 to SettingsView.var1, for each of the var listed in SettingsView, and possibly to other views as well. struct ContentView: View { var body: some View { VStack { if var1 { Text("Text") } } SettingsView() } } struct SettingsView: View { @AppStorage("var1") private var var1 = false @AppStorage("var2") private var var2 = true @AppStorage("var3") private var var3 = false @AppStorage("var4") private var var4 = MyType.Nested.value @AppStorage("var5") private var var5: Double? @AppStorage("var6") private var var6 = 0.0 @AppStorage("var7") private var var7 = 0.0 @AppStorage("var8") private var var8: String? @AppStorage("var9") private var var9: Data? @AppStorage("var10") private var var10 = true @AppStorage("var11") private var var11 = 0 var body: some View { Toggle("Var 1", isOn: $var1) ... } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftUI ShareLink doesn't show option "Copy" when sharing text
[quote='790572022, DTS Engineer, /thread/756748?answerId=790572022#790572022'] Removing the preview argument should work around the issue. [/quote] That's not possible, that argument is required when sharing an instance of Transferable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to NSProgressIndicator bindings don't do anything
But according to Progress documentation:: Each of the properties of a progress object, including totalUnitCount, completedUnitCount, and fractionCompleted, support key-value observing (KVO). This makes it extremely easy for a view or window controller object to observe the properties, and update UI elements, such as progress indicators, when the values change.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftUI Document App with UTType.directory
I'm having the same issue. This effectively prevents me from creating my app with SwiftUI, as opening directories is a central part of it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’24
Reply to iPad Pro 13" screenshots for the App Store
The App Store Connect API documentation still doesn't list the new iPads: https://developer.apple.com/documentation/appstoreconnectapi/screenshotdisplaytype When adding screenshots to 13" iPads on the website, they still seem to use the display type APP_IPAD_PRO_3GEN_129 when listed by the API, and uploading to that same type uploads them to the 13" display type instead, and then there is the requirement that one still has to upload screenshots for 12.9" display type, without an apparent way of doing so. I would expect to have an option to upload to 13" display type that is also used for 12.9" display type as well.
Replies
Boosts
Views
Activity
May ’24
Reply to Apple Care tells users who cannot download/update app from App Store that the third-party developer is responsible
Does the problem repeats with different users ? If so, just an idea: did you check their OS version ? Is it compatible with your deployment target ? Yes, the macOS version is compatible.
Replies
Boosts
Views
Activity
Apr ’24