The behavior of onDrag and onDrop in iOS 18 is different from previous versions.

I am developing an app that supports iOS 15 and later.

Up until iOS 17, the behavior of onDrag and onDrop was as follows:

  1. The item is moved by holding it and dragging it to the onDrop area.
  2. When the item is dropped in the onDrop area, the logic is executed, and simultaneously, the item disappears immediately.
  3. However, in iOS 18 the item remains for about 0.5 to 1.0 seconds before disappearing, even though there is no logic in the onDrop.

Is this the expected behavior, or is it a bug?"

Hwangho, can you please file a feedback with a project or a code snippet that reproduces the issue?

Ok, here is the snippet.

import SwiftUI

struct ContentView: View {  
   @State var str: String = "Drag me"

   var body: some View {
   VStack(spacing: 100) {
  
      Text(str)
       .frame(width: 100, height: 100)
       .background(.blue)
       .onDrag {
          NSItemProvider(object: String(str) as NSString)
       }
  
      VStack {
        Text("Drop Here!")
      }
      .frame(width: 200, height: 200)
      .background(.red)
      .onDrop(of: [.text], delegate: MyDelegate())
   }
  }
}

struct MyDelegate: DropDelegate {
    func performDrop(info: DropInfo) -> Bool {
        return true
    }
}

#Preview {
 ContentView()
}

i'm seeing the same issue - now that I think of it it did start after moving to iOS 18. Has anyone come up with a root cause/approach to solve this?

Have same issue

It is not the only problem. onDrag is re-called even after onDrop is successfully performed. Issue is only on iOS 18

I've reported this issue on FB and this issue will be fixed in 18.1!

The behavior of onDrag and onDrop in iOS 18 is different from previous versions.
 
 
Q