I had this problem as well and I believe what I did wrong was when I created the iCloud container ID I manually typed in the "iCloud" at the start of the bundle ID. For example I created the iCloud container ID as "iCloud.com.myBundleName.myCompany".
Xcode automatically adds the "iCloud" to the beginning of the name you type, so I believe what it was seeing was "iCloud.iCloud.com.myBundleName.myCompany" and thus giving the error.
Try just typing "com.whateverBundleName.whateverCompany" and Xcode will add the iCloud at the beginning automatically. That solved the error for me.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: