NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

Swift - Custom Crash handler for mobile applications

Forums > Swift

I would like to create my simple custom crash handler in swift to catch all my crashes or uncaught exceptions and save it locally, when user opens the app again, will send to server via service.

could you please suggest the best approach, best practices or any articles to achieve this?

Thanks in advance

   

You can set a handler to process exceptions with NSSetUncaughtExceptionHandler like below

NSSetUncaughtExceptionHandler { exception in
  // Implement your handling logic
}

   

@jannisnikoy : it catches only objective c exceptions

   

Hacking with Swift is sponsored by Paw

SPONSORED Use Paw to build, test and describe web APIs. Paw has a lightning fast native macOS interface to compose requests, collaborate in real-time on API specs, and generate client code for your applications. You can import and export API definitions.

Discover Paw for Mac

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.