I have a workable CoreData app (local storage).
I would like to make it workable with iCloudKit.
After migrating from NSPersistentContainer to NSPersistentCloudKitContainer (CoreDataStack.swift, line 21), I was hoping I can achieve success in the following testing.
Launch the app
Write a CoreData record for the first time.
Hopefully the data will then quietly sync to iCloud from device.
Delete the app
Install and launch the app again
Hopefully the old data before uninstall will quietly sync from iCloud to device.
Able read the old data before uninstall
However, I get stuck in step 2. After several attempts, I am still getting the following iCloud related error.
Here's the complete error log.
CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600001c0d050> containerIdentifier:iCloud.com.yocto.xxx databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600002c08770> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600002c08730> metricsClient:<PFCloudKitMetricsClient: 0x600002c087d0> metadataPurger:<PFCloudKitMetadataPurger: 0x600002c08790> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x600003b00b00> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x600002c08800>
storeOptions: {
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x60000204f0f0>";
NSPersistentHistoryTrackingKey = 1;
NSPersistentStoreMirroringOptionsKey = {
NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600001504a90>";
};
}
CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate observeChangesForStore:inPersistentStoreCoordinator:](385): <NSCloudKitMirroringDelegate: 0x600001504a90>: Observing store: <NSSQLCore: 0x131e151a0> (URL: file:///Users/yccheok/Library/Developer/CoreSimulator/Devices/F1F59F93-1800-4D43-AAE7-FD942D440B10/data/Containers/Data/Application/54000F75-F12A-4FF2-A2A1-545ACE41A367/Library/Application%20Support/xxx.sqlite)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration](530): <NSCloudKitMirroringDelegate: 0x600001504a90>: Successfully enqueued setup request.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](2928): <NSCloudKitMirroringDelegate: 0x600001504a90>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2941): <NSCloudKitMirroringDelegate: 0x600001504a90>: Executing: <NSCloudKitMirroringDelegateSetupRequest: 0x600003b51180> 428D83F5-B1E4-4BC6-B411-A9D0583983F0
success write Optional("title 0"), Optional("body 0")
2022-04-10 21:40:58.519262+0800 xxx[2918:70575] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1106): <NSCloudKitMirroringDelegate: 0x600001504a90>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x131e151a0> (URL: file:///Users/yccheok/Library/Developer/CoreSimulator/Devices/F1F59F93-1800-4D43-AAE7-FD942D440B10/data/Containers/Data/Application/54000F75-F12A-4FF2-A2A1-545ACE41A367/Library/Application%20Support/xxx.sqlite)
<CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1106): <NSCloudKitMirroringDelegate: 0x600001504a90>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x131e151a0> (URL: file:///Users/yccheok/Library/Developer/CoreSimulator/Devices/F1F59F93-1800-4D43-AAE7-FD942D440B10/data/Containers/Data/Application/54000F75-F12A-4FF2-A2A1-545ACE41A367/Library/Application%20Support/xxx.sqlite)
<CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
2022-04-10 21:40:58.519485+0800 xxx[2918:70575] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2115): <NSCloudKitMirroringDelegate: 0x600001504a90> - Attempting recovery from error: <CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2115): <NSCloudKitMirroringDelegate: 0x600001504a90> - Attempting recovery from error: <CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
2022-04-10 21:40:58.528209+0800 xxx[2918:70575] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromPartialError:forStore:inMonitor:]_block_invoke(2464): <NSCloudKitMirroringDelegate: 0x600001504a90>: Found unknown error as part of a partial failure: <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx">
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromPartialError:forStore:inMonitor:]_block_invoke(2464): <NSCloudKitMirroringDelegate: 0x600001504a90>: Found unknown error as part of a partial failure: <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx">
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](2959): Finished request: <NSCloudKitMirroringDelegateSetupRequest: 0x600003b51180> 428D83F5-B1E4-4BC6-B411-A9D0583983F0 with result: <NSCloudKitMirroringResult: 0x600002e6db00> success: 0 madeChanges: 0 error: <CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](2928): <NSCloudKitMirroringDelegate: 0x600001504a90>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2944): <NSCloudKitMirroringDelegate: 0x600001504a90>: No more requests to execute.
The following error draws my attention
Invalid bundle ID for container
I step-by-step the check, to ensure I have done the thing correctly.
Xcode Target Settings
My app Bundle identifier is com.yocto.xxx
My iCloud container is iCloud.com.yocto.xxx
iCloudKit Console
I can see the container iCloud.com.yocto.xxx is created in iCloudKit console.
I am still do not see my own app schema yet. It is a simple entity called Todo with two columns - https://github.com/yccheok/xxx/blob/main/xxx/xxx.xcdatamodeld/xxx.xcdatamodel/contents
Sandbox tester account
I created a sandbox tester account from App Store Connect/ Users and Access.
I then use the sandbox tester account, to login from web to https://www.icloud.com/. Login doesn't have any issues.
Login to Simulator
Login to simulator doesn't have any issue
Minimal reproducible example
Here's the Xcode I use for this testing
https://github.com/yccheok/xxx
What went wrong in between, which causes me to keep getting Invalid bundle ID for container? What other steps could I try?
This is how I solve the issue.
I was referring to this answer - CloudKit - "Invalid bundle ID for container"
What I did wrong was
I deleted my app id from https://developer.apple.com/account/resources/identifiers/list
I rerun the app via Xcode, and expecting the app id will be created automatically. But it doesn't. The app id will not be automatically created even if I run the app from Xcode.
So, what I did right was:
I create a new project with a new app id, and using a new iCloud container id too.
I launch the app for the first time.
From https://developer.apple.com/account/resources/identifiers/list, I click on the app id as shown in the following screenshot.
I untick and tick the checkbox for iCloud, click Save button in the top right.
Now, I can observe the data is being saved to iCloud. I have verified by uninstalling the app, installing the app and performing read. There isn't any issue of reading the old data.
Related
I'm trying to download a language translation model from Google MLKit. I can download the model successfully on the main iOS app, but when I try to download it on the keyboard extension app, I receive an error: "A server with the specified hostname could not be found."
testKeyboard[43687:3987699] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
testKeyboard[43542:3979636] [discovery] [d 6BF0C0BD-3B78-43CD-A23F-26023D59A4F3] <PKHost:0x283acc400> Failed discovery: Error Domain=PlugInKit Code=4 "Connection invalid" UserInfo={NSLocalizedDescription=Connection invalid}.
testKeyboard[43542:3979636] [xpc] XPC error sending request to pkd: Connection invalid
testKeyboard[43542:3979662] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service
testKeyboard[43542:3979662] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:9 Err:-1 Errno:1 Operation not permitted
testKeyboard[43542:3979662] [connection] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
testKeyboard[43542:3979662] Task <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1> HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000])
testKeyboard[43542:3979662] Task <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x2821c14a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDownloadTask <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://redirector.gvt1.com/edgedl/translate/offline/v5/high/r24/en_es.zip, NSErrorFailingURLKey=https://redirector.gvt1.com/edgedl/translate/offline/v5/high/r24/en_es.zip, _kCFStreamErrorDomainKey=10}
error downloading Optional(Error Domain=com.google.mlkit Code=2 "Failed to download the model from the server." UserInfo={NSLocalizedDescription=Failed to download the model from the server.})
I'm using the same code to download the model according to Google's "Translate Text with MLKit on iOS" documentation in the KeyboardViewController's viewDidLoad() function:
let options = TranslatorOptions(sourceLanguage: .english, targetLanguage: .spanish)
self.translator = Translator.translator(options: options)
let conditions = ModelDownloadConditions(allowsCellularAccess: true, allowsBackgroundDownloading: true )
self.translator!.downloadModelIfNeeded(with: conditions) { error in
guard error == nil else {
print("error downloading", error)
return
}
print("Model downloaded successfully")
}
My Info.plist settings are such:
"RequestsOpenAccess" as 1
"App Transport Security Settings" > "Allow Arbitrary Loads" as YES
I don't understand what is going on here. Why am I able to download the ML Kit language model on the main app, but not on the keyboard extension? Any help appreciated.
The issue is with your project's Sandbox settings. Go to your project page / Signing & Capabilities / App Sandbox (Xcode 13.2) and then enable Outgoing Connections (Client) which will allow your app to make http calls.
I am writing an app for MacOS and main feature will be syncing data to iCloud. All that I've already done is
- project with Core-Data and CloudKit options turned on,
- created a model and some basic routine to create model by importing file to app.
Since this is a large file, I am doing all actions in separate thread/dispatching a new queue. When I am debugging app, saving data to local db works fine, then data is syncing to cloud when app loose its focus and I have to say that it works, what I can say by querying the data in CloudKit dashboard. But there is a problem with syncing the data when I start import of the file and when during import I will switch to other app. After import finishes, I see the data is stored locally but it cannot sync to cloud. Instead I see the following error in console:
CoreData: debug: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: : Got: NSApplicationWillBecomeActiveNotification - 0
CoreData: debug: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: : Got: NSApplicationDidBecomeActiveNotification - 1
CoreData: CloudKit: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: - Already scheduled a block to respond to 'NSApplicationDidBecomeActiveNotification', 2 notifications since.
CoreData: debug: CoreData+CloudKit: -[PFCloudKitThrottledNotificationObserver noteRecievedNotification:]_block_invoke(49): : Executing 'AppActivateObserver' block for 'NSApplicationWillBecomeActiveNotification' clearing 2 iterations.
CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:: - Beginning automated export - AppActivationExport:
(null)
CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate executeMirroringRequest:error:: : Asked to execute request: 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03
CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate _scheduleAutomatedImportWithLabel:activity:completionHandler:: - Beginning automated import - AppActivationImport - in response to activity:
(null)
CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate executeMirroringRequest:error:: : Asked to execute request: 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke(714): : enqueuing request: 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03
CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke_2(724): Failed to enqueue request: 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03
Error Domain=NSCocoaErrorDomain Code=134417 "Request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'." UserInfo={NSLocalizedFailureReason=Request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'.}
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(2174): - Finished automatic export - AppActivationExport - with result: success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'." UserInfo={NSLocalizedFailureReason=Request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'.}
CoreData: warning: CoreData+CloudKit: -NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:: Finished request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' with result: success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'." UserInfo={NSLocalizedFailureReason=Request ' 41AA55D5-F8A9-4EA9-A12A-9CA05775EC03' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'.}
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke(714): : enqueuing request: 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9
CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke_2(724): Failed to enqueue request: 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9
Error Domain=NSCocoaErrorDomain Code=134417 "Request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'." UserInfo={NSLocalizedFailureReason=Request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'.}
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedImportWithLabel:activity:completionHandler:]_block_invoke(2150): - Finished automatic import - AppActivationImport - with result: success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'." UserInfo={NSLocalizedFailureReason=Request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'.}
CoreData: warning: CoreData+CloudKit: -NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:: Finished request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' with result: success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'." UserInfo={NSLocalizedFailureReason=Request ' 3D212164-ABDF-4A44-A31D-1D5A9B19A9D9' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'.}
CoreData: debug: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: : Got: NSApplicationWillResignActiveNotification - 0
CoreData: debug: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: : Got: NSApplicationDidResignActiveNotification - 1
CoreData: CloudKit: CoreData+CloudKit: -PFCloudKitThrottledNotificationObserver noteRecievedNotification:: - Already scheduled a block to respond to 'NSApplicationDidResignActiveNotification', 2 notifications since.
So what is said above - Error Domain=NSCocoaErrorDomain Code=134417 - cannot execute request because there is one pending... Looks like sync action is triggered twice...
Also, what I want to mention is - the app will sync correctly when I will restart app...
So now, all I do is:
AppDelegate:
lazy var persistentContainer: NSPersistentCloudKitContainer = {
let container = NSPersistentCloudKitContainer(name: "TestContainer")
// container.viewContext.automaticallyMergesChangesFromParent = true
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error {
fatalError("Unresolved error \(error)")
}
container.viewContext.mergePolicy = NSMergePolicy(merge: .mergeByPropertyObjectTrumpMergePolicyType)
})
return container
}()
and I've found some good practice to set merge policy as I did: container.viewContext.mergePolicy = NSMergePolicy(merge: .mergeByPropertyObjectTrumpMergePolicyType)
After import is finished in ViewController
do {
try managedContext!.save()
managedContext?.commitEditing()
} catch {
print(error)
return
}
And then is this problem with error in sync data as I mentioned above. For development I am using macOS 10.15.4 with Swift 5.2... Any hints? Probably there is some problem that I do not see at the moment. Any help is appreciated :)
I'm trying to play songs from Apple Music and it is failing with the following logs:
2019-09-26 00:15:57.790999+0200 [1886:463973] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:15:57.791129+0200 [1886:463973] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:15:57.792655+0200 [1886:464074] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:15:57.792770+0200 [1886:464074] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:15:57.794124+0200 [1886:464074] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
2019-09-26 00:15:59.670842+0200 [1886:463973] [SDKPlayback] -[MPMusicPlayerController prependQueueDescriptor] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1 "No commands provided." UserInfo={NSDebugDescription=No commands provided.}
2019-09-26 00:15:59.671051+0200 [1886:463973] [SDKPlayback] -[MPMusicPlayerController prepareToPlay] completed id=applicationMusicPlayer error: Error Domain=MPMusicPlayerControllerErrorDomain Code=1 "prepareToPlay without a queue" UserInfo={NSDebugDescription=prepareToPlay without a queue}
2019-09-26 00:15:59.681627+0200 [1886:464074] [MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x282930a80 name=iPhone uid=LOCAL> origin=Nastasia's iPhone-1280262988 bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}
2019-09-26 00:15:59.681787+0200 [1886:464074] [SDKPlayback] -[MPMusicPlayerController play] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x281319230 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}}}
2019-09-26 00:16:03.596320+0200 [1886:464071] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:16:03.596374+0200 [1886:464071] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:16:03.597965+0200 1886:464051] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:16:03.598079+0200 [1886:464051] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:16:03.599416+0200 [1886:464074] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:16:03.599456+0200 [1886:464074] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:16:03.599542+0200 [1886:464074] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
I also tried the official sample code project from Apple called Adding-Content-to-Apple-Music, and got similar results:
2019-09-25 23:20:37.268162+0200 [1738:432623] [RemoteControl] userIdentityForMediaRemoteOptions -❗️No user identity data. Using active account.
2019-09-25 23:20:37.333703+0200 [1738:432751] [SDKPlayback] -[MPMusicPlayerController prepareToPlayWithCompletionHandler:] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122" UserInfo={NSDebugDescription=Failed to send command 122, NSUnderlyingError=0x282eacff0 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2)" UserInfo={NSDebugDescription=Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=2}}}
2019-09-25 23:20:37.333721+0200 [1738:432562] [SDKPlayback] -[MPMusicPlayerController prepareToPlay] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122" UserInfo={NSDebugDescription=Failed to send command 122, NSUnderlyingError=0x282eacff0 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2)" UserInfo={NSDebugDescription=Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=2}}}
2019-09-25 23:20:37.337138+0200 [1738:432546] [MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x281498a80 name=iPhone uid=LOCAL> origin=Nastasia's iPhone-1280262988 bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}
2019-09-25 23:20:37.337529+0200 [1738:432562] [SDKPlayback] -[MPMusicPlayerController play] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x282ead260 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}}}
2019-09-25 23:20:37.342424+0200 [1738:432623] [Middleware] INVALIDATE: 0x2813842d0: Invalidated before returning a response. Re-requesting items.
2019-09-25 23:20:38.144321+0200 [1738:432323] [SDKPlayback] Failed validators id=applicationMusicPlayer: {(
play
)}
2019-09-25 23:20:38.944291+0200 [1738:432323] [SDKPlayback] Failed to get a valid response. Resetting expectations id=applicationMusicPlayer
The issue is sometimes randomly fixed by playing around with apps, going to Apple Music app, playing something there, killing it, coming back, and so on...
If someone has experienced similar issues then please let me know how to fix it.
Happens on iOS 12 & 13, iPhone 6s and iPhone 11, Apple Music account is in 3 months trial currently. All the music capabilities are present, being able to successfully get the developer token and music user token, both work fine with Apple Music API requests.
Seems like one of the reasons can be that I use musicPlayerController.prepend() function instead of setQueue(). Unfortunately, I was forced to use prepend() because of music player limitations.
Here is a short description of what my app needs to do:
The user starts playing a list of songs.
During the playback the app fetches a new list of songs from backend every 5-10 seconds and sets it as the new song queue. That means it is quite dynamic by means of what plays next.
Now when it comes to setting a new queue during playback, setQueue() is really bad at it. If I just call setQueue() then nothing will happen, the old queue will stay. However, if I call play() or prepareToPlay() after setQueue() then current playback will be stopped and the first song of the new queue will start playing. That's not what I want, I need to change the queue "behind the scenes" so that when the user hits "skip to next" in the app or iOS lock screen, then the new songs are playing. That's why I used prepend() - it works just fine, the current playback is not interrupted. The alternative - calling perform() on applicationQueuePlayer crashes with message "it takes too long" - deleting the old queue of 30 songs manually item-by-item is not that optimal, I guess.
So currently I see only one option - manually store a state which will tell if this is the first run or not. If yes, then call setQueue(), otherwise call prepend(). There is also no way to get the current queue to check myself if it is empty or not.
And regarding play() - it comes out to be not as simple function, as it seems. As I already mentioned above, play() triggers the new queue playback if I ever called setQueue() before. It was bringing me more problems because when I was calling setQueue() without play(), it was not doing anything, however each time I pressed pause/play - the player was jumping to the next song thanks to the earlier "silent" setQueue(). I had to implement another workaround of calling player.currentPlaybackRate = 1 instead of player.play(), which doesn't look nice. It would be great, if all this was somehow documented.
I'm using the Apple MusicKit in my app. I had the authorization setup correctly and everything was working fine for a long time. Recently since the update to iOS 12 I'm seeing these errors
2018-12-02 19:16:46.511567-0500 Project2[30649:3022463] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2018-12-02 19:16:46.512835-0500 Project2[30649:3022463] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2018-12-02 19:16:46.518199-0500 Project2[30649:3022586] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2018-12-02 19:16:46.518407-0500 Project2[30649:3022586] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2018-12-02 19:16:46.524685-0500 Project2[30649:3022586] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
Is anyone else facing the same issue? Is there some change that I'm supposed to make? Or redo the token? I see this asked on the apple developers forum with no response https://forums.developer.apple.com/thread/105635
I'm new to iCloud, and I've gotten it to work in the past, but I started getting this error:
-[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](771):
CoreData: Ubiquity: clifton~sim70A83865-2E36-5810-ABEE-88CBF9EED011:iCloudPilotPro
Using local storage: 1
It is soon followed by this error:
-[PFUbiquitySetupAssistant finishSetupWithRetry:](822):
CoreData: Ubiquity: <PFUbiquitySetupAssistant: 0x1095bc790>: Retrying after delay: 60
Error Domain=NSCocoaErrorDomain Code=134060 "The operation couldn’t be completed.
(Cocoa error 134060.)" UserInfo=0x1095c3740 {reason=Failed to migrate baseline, unable
to create ubiquity migration manager}
I've scoured the web for any mention of unable to create ubiquity migration manager and I haven't found anything. Core Data seems to run fine in my app, but iCloud won't sync.
Does anyone out there know what this means or have ideas of what I can try?