What you need is to get an entitlements file so the app can access your iCloud and write records using CloudKit.
Follow the steps to grant access to iCloud from your app:
1- Select the project in the Project Navigator, and then open the General tab.
2- In the Identity section, set your developer Apple ID to the Team dropdown menu. (If it is not available, add it in Xcode menu -> Preferences -> Accounts.
3- Go to Capabilities tab in the project properties and turn iCloud on. Then, select "Key-Value Storage" and "CloudKit".
4- Make sure these items are checked:
If all of the items are checked, then your app is ready to use CloudKit.