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?

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)
    }
}`

Overview

  • Your original code works fine both on iOS and macOS
  • Please test on latest Xcode beta

Code change

One small code change (API has changed) for the latest Xcode beta:

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

Tested on

  • macOS 13.0 Beta (22A5311f)
  • Xcode Version 14.0 beta 4 (14A5284g)

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