Sam noted this earlier:
Cocoa exceptions are no longer logged to the console.
Workaround: none yet.
Note: Trying to prepare applications for Mojave are hard when things have changed, which causes a Cocoa Exception. This results in a function silently failing, with no pointers or indication why. You must manually step through code until you find the line it fails on, then do research to figure out why that line fails.
This just bit me in a big way.
I was trying to work out the declares to detect Dark Mode, and used the following code:
#if TargetMacOS function IsDarkMode() as boolean // see https://developer.apple.com/documentation/appkit/nsappearance Declare Function NSClassFromString Lib "Foundation" (classname As CFStringRef) As Ptr Declare Function NSAppearanceCurrentApperance Lib "Foundation" Selector "currentAppearance:" (classname As Ptr) As Ptr Declare Function NSAppearanceName Lib "Foundation" Selector "name:" (obj As Ptr) As CFStringRef dim nsa as Ptr = NSClassFromString("NSAppearance") dim currentAppearance as Ptr = NSAppearanceCurrentApperance(nsa) if currentAppearance <> nil then dim name as string = NSAppearanceName(currentAppearance) if name = "NSAppearanceNameDarkAqua" then return true end if end if return false #else return false #endif end function
Looks good, right?
Except there are two flaws which are subtle but fatal.
Without fixing the flaws, this function dies silently mid-stream. And by "dies" I do not mean "crashes" or "throws an exception" - no. Instead, the thread just disappears. This is extremely hard to debug and very user unfriendly. Very non "Xojo" like.
• can anyone identify the flaws?
• can Xojo do something to prevent these types of errors from being so incredibly hard to find and fix?