Crash an application on NSException

  1. 2 months ago

    Sam R

    Jan 31 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    Peter Steinberger on Twitter, just posted a quick tip that reverts the current behavior of silent failures under recent versions of macOS.

    https://twitter.com/steipete/status/1223228727477272577

    Use NSUserDefaults to set the value of "NSApplicationCrashOnExceptions" to true and your application will crash like it used to. Thus generating a crash report, showing you what went wrong and where. Opposed to silent failures, which are hard to find in console.

    He also posted this one back in October 2019, but I didn't see it.
    https://twitter.com/steipete/status/1187770905767927809

  2. 8 weeks ago

    Scott C

    Feb 10 Pre-Release Testers, Xojo Pro twitter.com/ScottCadillac
    Edited 8 weeks ago

    Given that I have an MBS license, I put the following into the Open event of my app:

    #If TargetMacOS
      Var u As NSUserDefaultsMBS = NSUserDefaultsMBS.standardUserDefaults
      u.setBoolValue("NSApplicationCrashOnExceptions", True)
    #EndIf

    This seemed to update the auto-created file located at /Users/scott/Library/Preferences/com.mycompany.myapp.plist which now looks like the following:
    -image-
    I guess as long as that entry is in the plist file, the OS takes care of the rest?

    You always have the greatest pointers Sam, thanks again!

  3. Sam R

    Feb 11 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    @Scott Cadillac You always have the greatest pointers Sam, thanks again!

    Glad I could help.

    If you're on twitter; make sure you hit up @steipete and let him know it helped. I wouldn't have found this tip without him. I'd started trying to get into the depths of handling NSExceptions myself, simply so that I was aware when, where and what was happening.

  4. Norman P

    Feb 11 Pre-Release Testers, Xojo Pro outside enjoying the fresh air

    @Scott C Given ...

    FYI - Scott
    You can just add to the apps plist at build time by creating a text file named info.plist and then dragging it into the project
    It lets you add key / value pairs to your build apps default plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
    <plist version="0.9">
    <dict>
        <key>NSApplicationCrashOnExceptions</key><true/>
    </dict>
    </plist>
  5. Tim J

    Feb 11 Pre-Release Testers, Xojo Pro N. Phoenix, AZ

    Adding the Info.plist file for macOS apps is one of the best kept, documented secrets of Xojo :D

  6. Norman P

    Feb 11 Pre-Release Testers, Xojo Pro outside enjoying the fresh air
    Edited 8 weeks ago

    http://docs.xojo.com/UserGuide:Using_a_plist

    http://docs.xojo.com/Changes_2014r2
    and yer welcome :P

  7. Scott C

    Feb 11 Pre-Release Testers, Xojo Pro twitter.com/ScottCadillac

    @Norman P You can just add to the apps plist at build time by creating a text file named info.plist and then dragging it into the project
    It lets you add key / value pairs to your build apps default plist

    Thank you Norman for the link, I knew there was a mechanism for including a plist in a project, but hadn't had a chance to explore it much yet.

    With some of the things I'd like to do, I know I'll have to dig into this further eventually.

  8. Norman P

    Feb 11 Pre-Release Testers, Xojo Pro outside enjoying the fresh air

    I smell a blog post .....

  9. Sam R

    Feb 11 Pre-Release Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    @Norman P You can just add to the apps plist at build time by creating a text file named info.plist and then dragging it into the project
    It lets you add key / value pairs to your build apps default plist

    Does it work if added to the application plist?

    The usage described by @steipete is to set it to the defaults. Sadly it's undocumented, so there's no official word from Apple on this.

  10. Norman P

    Feb 11 Pre-Release Testers, Xojo Pro outside enjoying the fresh air

    Now I'll have to try that and see if a per app setting like this works as expected as it would be different from the user defaults

  11. Tim J

    Feb 12 Pre-Release Testers, Xojo Pro N. Phoenix, AZ

    @Sam R Sadly it's undocumented, so there's no official word from Apple on this.

    That just about sums development for Apple up in one sentence. >:(

or Sign Up to reply!