Xcode Error - Profile doesn't include the com.apple.developer.icloud-container-environment entitlement
Here's how I fixed it:
I created an iCloud container on the CloudKit dashboard (in the iCloud section of the Signing & Capabilities in Xcode).
I assigned the newly created container to my app (Developer Website > Certificates, Identifiers & Profiles > Identifiers > my app ID > Capabilities > iCloud > Edit button) and saved the app ID configuration.
Then I created a new App Store provisioning profile for this app ID and used it to manually sign the app when I uploaded it in Xcode.