Conforming system type to a protocol with `@MainActor` isolation while disabling the concurrency check gives unexpected error

  Kiến thức lập trình

I have the following code that worked well:

protocol URLLauncher {
  func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler: ((Bool) -> Void)?)
}
extension UIApplication: URLLauncher {}

It worked well on Xcode 16 beta 1&2. When I update to Xcode 16 beta 3, it gives me error complaining completionHandler should be main actor. This can be fixed by adding @MainActor to the completionHandler:

...completionHandler: (@MainActor(Bool) -> Void)?)

However, I don’t want to use any concurrency features yet. It’s odd that Xcode even gives me this error, because I don’t have concurrency checking enabled in my build settings. I have all SWIFT_UPCOMING_FEATURES_6_0 to be NO, and “Strict Concurrency Checking” to be “Minimal”.

Not sure if my code has any problem, or is it a bug in Xcode.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT