I am using WCSessionFileTransfer for transferring some files from WatchOS (10.5) to iPhone iOS 17.5.1
let session: WCSession = WCSession.default
session.delegate = self
session.activate()
...
...
...
fileTransfer = session.transferFile(file.url, metadata: ["alternateId" : file.alternateId, "type" : file.type])
The following delegate handles the file transferring result
func session(_ session: WCSession, didFinish fileTransfer: WCSessionFileTransfer, error: Error?) {
...
...
...
}
The problem is that the didFinish response from WCSessionDelegate does not fire at all.
Attaching the debug console I was able to retrieve the following error:
[WCFileStorage persistOutgoingFileTransfer:] error serializing file
transfer <WCSessionFileTransfer: 0x300155d60, session file:
<WCSessionFile: 0x3001575c0, identifier:
0C8857EC-7D74-4E78-BA28-6C5526DE8949, file:
FILE.EXT,
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 )}
Unfortunately this error is not forwarded to WCSessionDelegate
Am I doing anything wrong?
How can I handle this kind of error?
Is there any specific limit to the file that can be transferred using WCSessionFileTransfer?