0

I am running into an exception thrown by a 3rd party library written in objective c and it is causing my Swift app to terminate.

Here is what the debug info shows in Xcode:

2018-11-06 09:48:04.336769-0700 BACtrackSwift[331:12792] +[NSMutableData dataFromHexString:]: unrecognized selector sent to class 0x1effb6e28
2018-11-06 09:48:18.279085-0700 BACtrackSwift[331:12792] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSMutableData dataFromHexString:]: unrecognized selector sent to class 0x1effb6e28'

I don't have access to third party library obj c source and wondering what I can do on the Swift side to prevent or quiet this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Swizzle and add the method to `NSMutableData`.. and do what its name suggests lol. Create `NSMutableData` from a string of hex-bytes. – Brandon Nov 06 '18 at 16:53
  • 4
    You can't handle that exception in either language. The bug needs to be fixed. Since that is clearly a method added in a category, find the missing dependency that provides that category method. – rmaddy Nov 06 '18 at 16:54
  • 2
    How did you install that 3rd party lib? https://stackoverflow.com/questions/37220064/nsmutabledata-error ? – Larme Nov 06 '18 at 16:55
  • As in the post linked from @Larme, you've very likely failed to include `-objc` in your link steps, probably of a static library. See https://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library for how to add these. (And totally agreed w/ rmaddy. You cannot handle this exception. You have to resolve the issue.) – Rob Napier Nov 06 '18 at 17:30

0 Answers0