This can be done, for example, using https://github.com/williamFalcon/SwiftTryCatch . First add it to your subfile:
use_frameworks! pod 'SwiftTryCatch'
Then in your code import SwiftTryCatch , and then you can catch Objective-C exceptions like this
SwiftTryCatch.try({ // try block }, catch: { (error) in // catch block }, finally: { // finally block })
Leszek szary
source share