How to securely dispose of a smartphone?

Unless you have secrets on that phone that someone would pay a lot of money to uncover, you don't need to go overboard. A factory reset would work just fine.

To decrease the chances someone would still recover something, point the camera out of the window and let it record until it fills up all memory. Repeat if you want. Doing that will overwrite almost everything, and anything it could be recovered will mean too little to be of any use.

But if you have secrets that would make someone use a electron microscope on it, rent a clean room or spend hundreds of times the price of your phone to recover its data, physical destruction is the only safe option.

Under the assumption that you have a somewhat recent phone (Android 6+ installed from factory, I don't know for Apple but read something about from iPhone 6 on):

  • Wipe the phone/do a factory reset (assuming the phone is still working)

Modern devices always encrypt all the data and only delete the key for this encryption if you wipe it. This makes it impossible to restore data after wiping.

Under the assumption you do not trade state secrets I would:

  • Wipe the phone/do a factory reset (assuming the phone is still working)
  • Remove the SD Card (keep it for later use) (does not apply to the iPhone5, since it has none)
  • Open the phone
  • Locate the motherboard (the largest piece of printed circuit board)
  • Unseat or destroy the following chips as possible (See this iPhone5 Teardown Guide on iFixit for details):
    • Hynix H2JTDG2MBR 128 Gb (16 GB) NAND flash (on Step 15)
    • The A6 processor (on Step 16/18)
  • Dispose the parts at different times/different locations of an electronics recycling shop (Availability depends on country)

With this, an reassembly and successful extraction of data would be expensive and very unlikely.

Note: According to the iPhone Wiki, the A6 does not have a Secure Enclave, so nothing to do about that.