How to wipe an iPhone before selling it
If you plan to sell your old iPhone it’s really important that you wipe all personal data and completely erase it before doing so. By doing this, you’ll have complete peace of mind that your data will never get into the wrong hands and your personal information is completely safe.
Before you wipe your old iPhone, make sure you are completely happy that your new iPhone is 100% up to date and all of your photos, music, messages, emails and contacts are all there.
If this all checks out then follow some simple steps(taken from apple.com) to wiping your iPhone before selling it:
1 - Remove your personal information from your old device
2 - If you’ve paired an Apple Watch with your iPhone, unpair your Apple Watch.
3 - Back up your device.
4 - Sign out of iCloud and the iTunes & App Store.
5 - If you’re using iOS 10.3 or later, tap Settings > [your name]. Scroll down and tap Sign Out. Enter your Apple ID password and tap Turn Off.
6 - If you’re using iOS 10.2 or earlier, tap Settings > iCloud > Sign Out. Tap Sign Out again, then tap Delete from My [device] and enter your Apple ID password. Then go to Settings > iTunes & App Store > Apple ID > Sign Out.
7 - Go back to Settings and tap General > Reset > Erase All Content and Settings. If you’ve turned on Find My [device], you might need to enter your Apple ID and password. Forgot your Apple ID or your Apple ID password?
8 - If asked for your device passcode or Restrictions passcode, enter it. Then tap Erase [device].
9 - If you’re switching to a non-Apple phone, deregister iMessage.
10 - Contact your network provider for help transferring service to a new owner. If you aren’t using a SIM card with your device, you can contact them to get help transferring service to the new owner.
11 - Remove your old device from your list of trusted devices.