SWIFT TASK CONTINUATION MISUSE: loadTransferable(for:) leaked its continuation!

I try use dropDestination(payloadType: String.self) in iOS 16 instead of  .onDrop(of: [.plainText], ..., in iOS 15, but it doesn't work and I have

SWIFT TASK CONTINUATION MISUSE: loadTransferable(for:) leaked its continuation!

import SwiftUI

struct ContentView: View {

    @State var text: String = "🍌🍌"

        var body: some View {

            HStack {

                //  Text to drag

                Text(text)

                    .font(.title)

                    .draggable(text)

                /*    .onDrag { NSItemProvider(object: self.text as NSItemProviderWriting) }*/

                //  Area to drop

                RoundedRectangle(cornerRadius: 10)

                    .frame(width: 150, height: 150)

                   .dropDestination(payloadType: String.self) { (strings: [String], location) in

                        self.text = "Dropped My Bananas 🍌🍌!"

                        return true

                    }

                 /*   .onDrop(of: [.plainText], isTargeted: nil, perform: { _ in

                        self.text = "Dropped My Bananas 🍌🍌!"

                        return true

                    })*/

            }

        }

}

What wrong with my code?
Post not yet marked as solved Up vote post of WildGrey Down vote post of WildGrey
295 views

Replies

Can confirm, I get the same results with this simple code

struct ContentView: View {

    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
                .draggable(Load(index: 1))
            Text("Hello, world!")
                .dropDestination(payloadType: Load.self, action: {(_, _) in return true})
        }
    }
}

struct Load: Transferable, Codable {
    var index: Int

    static var transferRepresentation: some TransferRepresentation {
            CodableRepresentation(contentType: .load)
    }
}`