I have the following code to import the UICloudSharingController into swift UI but when integrated the first time up it just shows an activity indicator that never stops and then the second time it is presented (via .sheet), there is no activity indicator. The first time up I can see the close button to the top right corder with activity indicator. Any feedback would be appreciated.
struct CloudSharingController: UIViewControllerRepresentable {
typealias UIViewControllerType = UICloudSharingController
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject, UICloudSharingControllerDelegate {
func cloudSharingController(_ csc: UICloudSharingController, failedToSaveShareWithError error: Error) {
print("asdf")
}
func itemTitle(for csc: UICloudSharingController) -> String? {
return "item title for sharing TTT"
}
var parent: CloudSharingController
init(_ cloudSharingController: CloudSharingController) {
self.parent = cloudSharingController
}
}
var share: CKShare? = nil
var container: CKContainer = CKContainer.default()
var firsTimeBlock: ((UICloudSharingController, @escaping (CKShare?, CKContainer?, Error?) -> Void) -> Void)? = nil
func makeUIViewController(context: UIViewControllerRepresentableContext<CloudSharingController>) -> CloudSharingController.UIViewControllerType {
let result: UICloudSharingController!
if let validFirstBlock = firsTimeBlock {
return UICloudSharingController(preparationHandler: validFirstBlock)
} else if let validShare = self.share {
return UICloudSharingController(share: validShare,
container: container)
} else {
fatalError()
}
result.availablePermissions = [.allowReadWrite]
// result.popoverPresentationController?.sourceView = AccountsView
result.delegate = context.coordinator
return result
}
func updateUIViewController(_ uiViewController: CloudSharingController.UIViewControllerType, context: UIViewControllerRepresentableContext<CloudSharingController>) {
}
}