UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: SwiftUI App failing to sync CloudKit data - but only in TestFlight version

Forums > SwiftUI

Hi folks

I have a SwiftUI app that I have distributed to my testers. I have deployed my development schema to production cleanly and I have also tested with com.apple.developer.icloud-container-environment in entitlements set to "Production". However what I am finding is that when I compile and run the app via Xcode, all is well. My test devices and simulators are sharing the data as I'd expect, in both the development and production private and public databases.

However, when I package it up, I've tried manual and automatic signing, and release it through TestFlight and load it into the same physical devices that previously worked via Xcode, no syncing occurs, it just seems to write to local store.

Then when I connect to Xcode and rerun the app, overwriting the TestFlight version (i.e. I'm not deleting the local store, just the app) the records I created with the TestFlight version will now make their way to the Production database.

I am guessing that I have goofed somewhere along the line with certificates, but I have recreated new provisioning profiles and new certificates - I admit I find this part confusing, I'm quite new to this - but to no avail. I've read through the documentation and searched the web, but I'm not getting any leads. Any suggestions on what I am doing wrong would be gratefully received.

Thanks,

Ian

3      

Is the cloud in private database?

When you run in Xcode you able to see as it goes to your developer's cloud, however on your devic from TestFlight it goes to your private cloud which developer do not have access to. This is the same as your testers. To check download on two different devices that have same apple id and see if synced between them.

3      

Thanks for coming back to me Nigel.

The app contains both, private and public. Neither are recieving any records. The public one should be visible to all. After initial creation the records do appear on one screen, but I am 99% certain that these are coming from the local copy of the public database. On Cloudkit Console, they never arrive in either my private or public databases. Interestingly on another screen they do not appear, but the core data fetch on this other screen is also checking to see if the user owns the record, and therefore could edit it. I am guessing this flag is added to the Cloudkit version in the background.

I think I must have messed up certificates or provisioning profiles or something. But without being able to execute the TestFlight version from Xcode, I can't see where the problem is happening.

3      

I believe I have found the problem - and it was indeed me being incredibly stupid. In Xcode, I had created the entitlements, but only under debug and not release. Yeah, real stupid one. But I leave this here for anyone else who may also be scratching their heads.

3      

Hi @snark2021, thanks for posting this - I have the same problem, but I don't understand your solution.

My App works fine on all my devices, but it won't pull down CoreData records from testing devices on TestFlight. Are you able to gove me a few pointers on how to permission the testers for the CoreData Cloudkit public database? Each tester has been assigned "developer" status and are "internal" or part of my development team on the Apple TestFlight scheme.

Thank you.

Rob

2      

I have a smiliar problem. When I install my app over TestFlight (only internal testing available) my data won't sync over iCloud. My other testers though can install it over TestFlight and the data syncs. For me it only works if I install the app over Xcode no my phone and watch. Then it does work even when disconnected from Xcode.

2      

@Hatsushira, I managed to get to the bottom of the problem - at least on my setup. When using TestFlight, testers are pointed to the "produciton" database and not the "development" area. As I understand it, there is no way to let testers acceess the development area. When I realised that, I pushed my database into production, deleted the XCode installed version on my phone, and installed the test version from TestFlight. As I re-populated the production database from the TestFlight version of the app on my phone, the recorder became available for other TestFlight users.

I hope that makes sense and gives you a few pointers.

Good luck!

4      

@rjukes Thank you very much for the hints. I will try this when I'm at home and will give feedback!

2      

I could deploy the container to production from my phone and now it works. Thank you. This was the problem.

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.