{"id":31002,"date":"2020-12-11T16:16:42","date_gmt":"2020-12-11T21:16:42","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=31002"},"modified":"2022-05-05T13:48:50","modified_gmt":"2022-05-05T17:48:50","slug":"swift-concurrency-interoperability-with-objective-c","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/12\/11\/swift-concurrency-interoperability-with-objective-c\/","title":{"rendered":"Swift Concurrency Interoperability With Objective-C"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/main\/proposals\/0297-concurrency-objc.md\">SE-0297<\/a> (via <a href=\"https:\/\/twitter.com\/dgregor79\/status\/1337148873656004609\">Doug Gregor<\/a>):<\/p>\n<blockquote cite=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/main\/proposals\/0297-concurrency-objc.md\"><p>The proposed solution provides interoperability between Swift&rsquo;s concurrency constructs and Objective-C in various places. It has several inter-dependent pieces:<\/p><ul><li>Translate Objective-C completion-handler methods into <code>async<\/code> methods in Swift.<\/li><li>Allow <code>async<\/code> methods defined in Swift to be <code>@objc<\/code>, in which case they are exported as completion-handler methods.<\/li><li>Provide Objective-C attributes to control over how completion-handler-based APIs are translated into <code>async<\/code> Swift functions.<\/li><\/ul><p>The detailed design section describes the specific rules and heuristics being applied. However, the best way to evaluate the overall effectiveness of the translation is to see its effect over a large number of Objective-C APIs. <a href=\"https:\/\/github.com\/DougGregor\/swift-concurrency-objc\/pull\/1\">This pull request<\/a> demonstrates the effect that this proposal has on the Swift translations of Objective-C APIs across the Apple iOS, macOS, tvOS, and watchOS SDKs.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/12\/07\/swift-proposal-for-async-await\/\">Swift Proposal for async\/await<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/11\/03\/swift-concurrency-roadmap\/\">Swift Concurrency Roadmap<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>SE-0297 (via Doug Gregor): The proposed solution provides interoperability between Swift&rsquo;s concurrency constructs and Objective-C in various places. It has several inter-dependent pieces:Translate Objective-C completion-handler methods into async methods in Swift.Allow async methods defined in Swift to be @objc, in which case they are exported as completion-handler methods.Provide Objective-C attributes to control over how completion-handler-based [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2020-12-11T21:16:45Z","apple_news_api_id":"7b6664d3-3d29-42ff-9210-f4085ffd629c","apple_news_api_modified_at":"2022-05-05T17:48:55Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/Ae2Zk0z0pQv-SEPQIX_1inA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[800,880,46,54,71,2200,901],"class_list":["post-31002","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-concurrency","tag-grand-central-dispatch-gcd","tag-languagedesign","tag-objective-c","tag-programming","tag-swift-concurrency","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31002","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=31002"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31002\/revisions"}],"predecessor-version":[{"id":31003,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31002\/revisions\/31003"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=31002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=31002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=31002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}