File transfer issue from iPhone to Watch after iOS 17.5 & WatchOS 10.5 update

After updating to iOS 17.5 & WatchOS 10.5, the didFinish response from WCSessionDelegate does not come when transferring files from iPhone to Watch.

It worked normally until 17.4 & 10.4.

There is no problem with checking file completion even if a didFinish response is not received, but I think Apple needs to check this issue and update.

File transfer is done using the transferFile function of WCSession. The file being transferred is a single file and its size does not exceed 30MB.

When you try to transfer Pi, the message below appears in the Xcode log section.

-[WCFileStorage persistOutgoingFileTransfer:] error serializing file transfer <WCSessionFileTransfer: 0x300155d60, session file: <WCSessionFile: 0x3001575c0, identifier: 0C8857EC-7D74-4E78-BA28-6C5526DE8949, file: /private/var/mobile/Containers/Data/Application/DD797847-DED1-42C0-989F-34CD05825007/tmp/C042D096-F12B-4B50-8792-868475DBBF47.zip, hasMetadata: YES>, transferring: YES> due to Error Domain=NSCocoaErrorDomain Code=4866 "Caught exception during archival: This object may only be encoded by an NSXPCCoder. ( 0 CoreFoundation 0x000000019b064f2c 00E76A98-210C-3CB5-930B-F236807FF24C + 540460 1 libobjc.A.dylib 0x0000000192ef6018 objc_exception_throw + 60 2 Foundation 0x0000000199fe7778 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 1419128 3 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428 4 WatchConnectivity 0x000000021d055f60 1AB4DDD6-9238-3965-B744-819F2916C8CC + 126816 5 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428 6 WatchConnectivity 0x000000021d0567f0 1AB4DDD6-9238-3965-B744-819F2916C8CC + 129008 7 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428 8 Foundation 0x0000000199f30628 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 669224 9 WatchConnectivity 0x000000021d0583ac 1AB4DDD6-9238-3965-B744-819F2916C8CC + 136108 10 WatchConnectivity 0x000000021d04390c 1AB4DDD6-9238-3965-B744-819F2916C8CC + 51468 11 WatchConnectivity 0x000000021d046640 1AB4DDD6-9238-3965-B744-819F2916C8CC + 63040 12 Foundation 0x0000000199ea9be0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117728 13 Foundation 0x0000000199ea9aa0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117408 14 Foundation 0x0000000199ea98a0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 116896 15 Foundation 0x0000000199ea7b40 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 109376 16 Foundation 0x0000000199f2c558 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 652632 17 Foundation 0x0000000199f2c1a4 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 651684 18 libdispatch.dylib 0x0000000105ed7764 _dispatch_block_async_invoke2 + 148 19 libdispatch.dylib 0x0000000105ec67bc _dispatch_client_callout + 20 20 libdispatch.dylib 0x0000000105ec98e0 _dispatch_continuation_pop + 676 21 libdispatch.dylib 0x0000000105ec8bb8 _dispatch_async_redirect_invoke + 680 22 libdispatch.dylib 0x0000000105edaae4 _dispatch_root_queue_drain + 404 23 libdispatch.dylib 0x0000000105edb4d8 _dispatch_worker_thread2 + 188 24 libsystem_pthread.dylib 0x00000001f7ebb8f8 _pthread_wqthread + 228 25 libsystem_pthread.dylib 0x00000001f7eb80cc start_wqthread + 8 )" UserInfo={NSDebugDescription=Caught exception during archival: This object may only be encoded by an NSXPCCoder. ( 0 CoreFoundation 0x000000019b064f2c 00E76A98-210C-3CB5-930B-F236807FF24C + 540460 1 libobjc.A.dylib 0x0000000192ef6018 objc_exception_throw + 60 2 Foundation 0x0000000199fe7778 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 1419128 3 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428 4 WatchConnectivity 0x000000021d055f60 1AB4DDD6-9238-3965-B744-819F2916C8CC + 126816 5 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428 6 WatchConnectivity 0x000000021d0567f0 1AB4DDD6-9238-3965-B744-819F2916C8CC + 129008 7 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428 8 Foundation 0x0000000199f30628 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 669224 9 WatchConnectivity 0x000000021d0583ac 1AB4DDD6-9238-3965-B744-819F2916C8CC + 136108 10 WatchConnectivity 0x000000021d04390c 1AB4DDD6-9238-3965-B744-819F2916C8CC + 51468 11 WatchConnectivity 0x000000021d046640 1AB4DDD6-9238-3965-B744-819F2916C8CC + 63040 12 Foundation 0x0000000199ea9be0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117728 13 Foundation 0x0000000199ea9aa0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117408 14 Foundation 0x0000000199ea98a0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 116896 15 Foundation 0x0000000199ea7b40 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 109376 16 Foundation 0x0000000199f2c558 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 652632 17 Foundation 0x0000000199f2c1a4 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 651684 18 libdispatch.dylib 0x0000000105ed7764 _dispatch_block_async_invoke2 + 148 19 libdispatch.dylib 0x0000000105ec67bc _dispatch_client_callout + 20 20 libdispatch.dylib 0x0000000105ec98e0 _dispatch_continuation_pop + 676 21 libdispatch.dylib 0x0000000105ec8bb8 _dispatch_async_redirect_invoke + 680 22 libdispatch.dylib 0x0000000105edaae4 _dispatch_root_queue_drain + 404 23 libdispatch.dylib 0x0000000105edb4d8 _dispatch_worker_thread2 + 188 24 libsystem_pthread.dylib 0x00000001f7ebb8f8 _pthread_wqthread + 228 25 libsystem_pthread.dylib 0x00000001f7eb80cc start_wqthread + 8 )}

Answered by rolf.fox@4iiii.com in 794999022

I have tried out the workaround suggested by Ziqiao Chen - using the Progress property of WCSessionFileTransfer.progress - so far in testing this has worked very well as a substitute for the session(_:didFinish:error:) callback. Seems to me that an advantage of this approach is that it happens all on the Watch side, and you don't have to rely on receiving a message from the companion app.

I followed the usage pattern exemplified in the sample project "Implementing Two-Way Communication Using Watch Connectivity" - see the FileTransferObservers class.

Thanks again, Ziqiao!

Can you please file Feedback and post the number here so we can investigate?

Same issue. Transferred images no longer appear on the Watch app.

We're having a similar issue transferring from Watch to Phone. The files transfer, but the completion is never notified so the files are left on the Watch. We had no issues with previous versions, this only started happening after devices were updated to iOS 17.5 and watchOS 10.5. This is critical functionality for us, so we need to have this resolved quickly.

The same bug, performing the same operations as author does. Providing empty metadata in transferFile method doesn't help either, outcome is the same. I am on iOS 17.5 and watchOS 10.5

Was really excited to discover Xcode 15.4 seeing my Apple Watch again after 15.3 refused to display it. But this new bug is clouding the sky again and blocking this part of development.

the very same as reported from several users happens with our app on a watchOS 10.5 watch and iOS 17.5 iPhone, having this solved as soon as possible is very important

I am seeing the same thing. It is only an issue with iOS 17.5. Sending from iOS 17.4 to watchOS 10.5 worked fine, but not sending from iOS 17.5.

Same here since 17.5, not solved in 17.5.1

FWIW I see the error message, but the files are sent from phone and received on watch fine for me.

I'm on iOS 17.5.1, watchOS 10.5, Xcode 15.4

+1 to the same bug report Found this issue when updated to iOS 17.5 and watchOS 10.5

Still using Xcode 15.2, as my Xcode 15.4 doesn't detect my Apple Watch. That is another issue.

But the file transfer from iPhone to Apple Watch works. However, there is notification that the file transfer is complete or not. This issue started to happen since the latest update watchOS 10.5

I run into the same problem when transferring a file from WatchOS to iPhone.

How can I handle this kind of error? The callback session(_ session: WCSession, didFinish fileTransfer: WCSessionFileTransfer, error: Error?) did not fire at all and the file transfer gets stuck.

I have the same problem. My watch app maintains a send queue of files to send to my iOS companion app. In watchOS 10.5, didFinishFileTransfer is never called. Hence my watch app never removes files from the queue and sends the same files repeatedly, even though the files do successfully make it to my iOS companion app. I just released a version of my iOS companion app that ignores transferred files it believes is have been previously received. I never needed to do that when didFinishFileTransfer was called. However, I wonder if I need to find a way to remove the files from my send queue. I could send a list of the files recently received from my iOS app back to my watch app so that my watch app could remove them from the queue. I'm going to wait and hope that Apple fixes this bug in a future release, in which case my watch app will send all the files again and my iOS app will ignore them. However, didFinishFileTransfer will be called and my watch app will remove the files from the queue. I did file a report with the Apple Feedback Assistant.

Are there any updates on this? We've developed a workaround, but we're still a few weeks away from being able to release the update, and our current users are unable to fully use the app if they've updated their Watch and/or Phone.

Also having the same problem with WCSessionFileTransfer. The didFinish fileTransfer delegate method is never called anymore.

I also successfully used the solution with sending a custom message from the Watch OS app to the iOS app once the file received.

I also noticed that the WCSession keeps all oustandingFileTransfers. I clean them by checking the progress, and cancelling them manually and do some custom cleanup.

for fileTransfer in session.outstandingFileTransfers {
       if (fileTransfer.progress.isFinished) {
               fileTransfer.cancel()
               didFinish(fileTransfer) // my method
         }
 }

Hopefully Apple fixes this issue soon.

The bug - failure to invoke didFinishFileTransfer - still seems present in 10.6 beta for me. Has anyone else tried 10.6 beta?

Also having the very same problem here with my app:

-[WCFileStorage persistOutgoingFileTransfer:] error serializing file transfer <WCSessionFileTransfer: 0x17dbe7d0, session file: <WCSessionFile: 0x17dc8190, identifier: 897CD06F-7EE0-4B9A-9411-4A42F4D1BEDB, file: /var/mobile/Containers/Data/PluginKitPlugin/68629D41-4733-420A-842E-48A2532FAE56/Documents/blob.data, hasMetadata: NO>, transferring: YES> due to Error Domain=NSCocoaErrorDomain Code=4866 "Caught exception during archival: This object may only be encoded by an NSXPCCoder.

The file arrives at the phone but the didFinishFileTransfer on watch's delegate never gets called. Because of this, the files are kept in queue and keep being synced to phone app repeatedly consuming watch battery.

Also happens on simulator. iOS 17.5.1 watchOS 10.5.

File transfer issue from iPhone to Watch after iOS 17.5 &amp; WatchOS 10.5 update
 
 
Q