Xcode Error Provisioning Profile Cannot Be Found After Deleting Expired Profile

Tried to rebuilding an app from the day or older you might run into this error.

Code Sign Error: Provisioning Profile (long string) can't be found.

This error is causes due to the xcode project file is messed up, mostly when you have an old project and created that with an older version of sdk or xcode. To solve this open up the project file in a text editor.

Navigate to your .xcodeproj file and open with Terminal. Do a “ls” command and you should see a *.pbxproj file and a few others. Open that file.

open project.pbxproj

Erase the lines which begins with “PROVISIONING_PROFILE”. e.g.

PROVISIONING_PROFILE = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";

Save and close the text editor. Reopen the project in Xcode, the error should have been fixed now.

If this does not fix the issue this approach from stackoverflow