make sure your Xcode set the Profile scheme as Debug than Release.
1. download the firmware from ref.
2. use iTunes press option and Restore to restore the firmware which you downloaded in step1.
3. 1015 error appear, dont’ care click ok.
4. open console on mac:
. / iRecovery -s
setenv auto-boot true
5. Now unplug your iPhone and turn it off by pressing the home+power button
6. Once it is off, turn it on by pressing the power button. Plug-in your iPhone and load iTunes to continue with the activation.