ShareLink + Preview equals crash

I am trying to use the new ShareLink component in an app I am moving to SwiftUI. If I use the init(items: Data, subject: Text?, message: Text?) variant of the initializer all works well. However if I try to include a preview using the initializer that takes an additional parameter that is a SharePreview instance I get a crash.

The crash complains about Fatal error: SWIFT TASK CONTINUATION MISUSE: data(contentType:) tried to resume its continuation more than once, throwing exportFailed!

thread #2, queue = 'com.apple.root.user-initiated-qos.cooperative', stop reason = Fatal error: SWIFT TASK CONTINUATION MISUSE: data(contentType:) tried to resume its continuation more than once, throwing exportFailed!

The creation of the SharePreview object itself succeeds with nothing. Its the initialization of the ShareLink object that goes boom.

Any ideas? Known issue? Wait for next beta?

Environment:

Xcode 14 beta 2, iOS 16 beta 2, iPhone 8

Answered by hotngui in 723653022

Using Xcode 14 beta 5 I no longer get the crash. However, now when I include the SharePreview the list of apps for sharing contains nothing except an action to create a quick note.

Update: I just tried with Xcode and iOS beta 3 and got the same crash.

I'm seeing the same thing in my code.

I just tried again with Xcode 14 beta 4 / iOS 16 beta 4 - same crash. I do now get the following in the debugger console. I do not use continuations in this particular app and it shows up when I tap the ShareLink.

_Concurrency/CheckedContinuation.swift:184: Fatal error: SWIFT TASK CONTINUATION MISUSE: data(contentType:) tried to resume its continuation more than once, throwing exportFailed!

2022-07-27 11:19:58.818137-0700 ItsAlmostTime[575:16531] _Concurrency/CheckedContinuation.swift:184: Fatal error: SWIFT TASK CONTINUATION MISUSE: data(contentType:) tried to resume its continuation more than once, throwing exportFailed!
Accepted Answer

Using Xcode 14 beta 5 I no longer get the crash. However, now when I include the SharePreview the list of apps for sharing contains nothing except an action to create a quick note.

ShareLink + Preview equals crash
 
 
Q