'Cannot add Push Notifications to Debug in Xcode 13

I get the following error in the console when running the app:

[Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: no valid “aps-environment” entitlement string found for application

In Capabilities I have added "Push Notifications" but it only seems to be added to the Release build. In "All" it says Push Notifications (Release) If I go to the Debug tab and add Capabilities, I can see Push Notifications; however, if I double click it or drag it in, nothing happens. It does not add nor show and there is no error thrown.

I presume the error I receive in the console is due to the missing capability for debug which I cannot seem to add unlike for release. Remote notifications are also checked in the "Background Modes" section.



Solution 1:[1]

i had also this problem. I HAVE SOME WORK AROUND FOR THIS.. NOT SURE HOW ITS WORK IN PRODACTION. what i did is copy the entitlements file and change is name from testRelease.entitlements to test.entitlements

test is the name of app

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeffrey