Use Find My iPhone to erase the device remotely
Put the iPhone into Recovery Mode
Connect the iPhone to a Mac or PC
Open Finder on macOS Catalina or later
Open iTunes or Apple Devices app on Windows or older macOS
Select the iPhone when it appears
Choose Restore when prompted
Wait for the restore process to complete
Set up the iPhone again after erasing
Restore from an iCloud or computer backup if available
Contact Apple Support if Recovery Mode does not work
