The <docs> say that `suspend` functions are availa...
# ios
p
The docs say that
suspend
functions are available as functions with callbacks and
async
functions in swift. Unfortunately this means that interfaces with
suspend
functions in Kotlin are exported as protocols with both
async
and callback requirements in Swift. And
async
is not supported for iOS 12 🙃 Is it possible to generate only the callback definitions?
More info https://forums.swift.org/t/concurrency-interoperability-with-objective-c/41616 Specifically
• Another issue is when an asynchronous completion-handler method is part of an Objective-C protocol. For example, the `NSURLSessionDataDelegate` protocol 1 includes this protocol requirement:
• - (void)URLSession:(NSURLSession*)session
• dataTask:(NSURLSessionDataTask *)dataTask
• didReceiveResponse:(NSURLResponse *)response
• completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler;
• Existing Swift code might implement this requirement in a conforming type using its completion-handler signature
• func URLSession(
• _ NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse: NSURLResponse,
• completionHandler: (NSURLSessionResponseDisposition) -> Void) { ... }
• while Swift code designed to take advantage of the concurrency model would implement this requirement in a conforming type using its
async
signature
• func URLSession(_ NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse: NSURLResponse) async -> NSURLSessionResponseDisposition { ... }
• Implementing both requirements would produce an error (due to two Swift methods having the same selector), but under the normal Swift rules implementing only one of the requirements will also produce an error (because the other requirement is unsatisfied). Swift’s checking of protocol conformances will be extended to handle the case where multiple (imported) requirements have the same Objective-C selector: in that case, only one of them will be required to be implemented.