Fixing Vague Swift Error Logs

libc++abi.dylib: terminating with uncaught exception of type NSException

Ever seen an error message that looks like this? Frustrated with how it basically doesn’t tell you anything about the actual issue? The good news is that you can make these error messages much more informative with one easy trick! 

Head to your scheme list and click it to access the drop down. Select Edit Scheme to access your scheme settings.

Choose Edit Scheme…

Make sure you’ve got the Run option selected on the left sidebar. Under Arguments -> Environment Variables, look for the variable named OS_ACTIVITY_MODE. Uncheck this variable.

Run your build again and navigate to where the error was happening. You should now be able to see the full stack trace of the exception being thrown.


FYI, you may not want to leave this setting off permanently in your schemes though unless you don’t mind a lot of extraneous logging from other core iOS systems clogging up your console.

In case you’re interested in how this setting ended up in your project, we have to take a journey back a couple of years. When the Xcode 8 betas were first released, they contained a lot of extraneous logging from the OS level frameworks. Adding this environment variable was the solution that most people ended up using for their projects. Unfortunately for developers Swift error messages became a little harder to decipher, but hopefully with this knowledge, you’ll be able to toggle this setting when necessary.

Leave a Reply