개요
XCode16을 사용하여 iOS 18 타겟하는 앱 빌드 시 발생할 수 있는 에러입니다.
Type 'UIApplication' does not conform to protocol 'Launcher'
Candidate has non-matching type '(URL, [UIApplication.OpenExternalURLOptionsKey : Any], (@MainActor @Sendable (Bool) -> Void)?) -> Void' (UIKit.UIApplication)
해결 방법
이 문제는 6.3.0 이하 버전 url_launcher_ios 플러그인과 iOS 18이 호환되지 않아 발생하는 문제입니다. 아래 명령어를 통해 url_launcher_ios 플러그인을 6.3.1 버전 이상으로 업그레이드하세요.
flutter pub add url_launcher_ios
flutter clean
cd ios
pod install
원인
애플이 iOS 18 beta3 부터 openURL completionHandler에 @MainActor (메인쓰레드 실행) 및 @Sendable (동시성 문제 방지) 속성을 추가했습니다. 내부적인 변화에 따라 플러그인도 업데이트되어야 했습니다.
iOS 18 Beta 3 added `@MainActor @Sendable` for openURL's completion handler:
```
@available(iOS 10.0, *)
open func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:], completionHandler completion: (@mainactor @sendable (Bool) -> Void)? = nil)
```
The addition of `@MainActor` is the one that caused the compile error. It was not there for Beta 1.
This PR we simply use a `DefaultLauncher` wrapper. As expected, passing in a **non-isolated closure** to a function that expects a **main-actor isolated closure** is fine, since non-isolated closure can be called in any isolation context; plus the minimal concurrency checking also silences the Sendable warning.
But we should check again in newer betas if we can revert this change. Because this compile error forces some libraries to update for swift concurrency, which seems to be against the whole idea of having 3 different levels of concurrency checking. So I suspect that Apple is still hashing things out and may change it back (either by removing `@MainActor` from signature, or compiler change to allow this conformance under minimal checking)
*List which issues are fixed by this PR. You must list at least one issue.*
Fixes flutter/flutter#151467
참고 자료
'프로그래밍 > Flutter <Dart>' 카테고리의 다른 글
[Flutter] Incorrect use of ParentDataWidget 에러 해결 (0) | 2024.09.18 |
---|---|
[Flutter] flutter_inappwebview iOS 18 Ambiguous use of 'evaluateJavaScript(_:completionHandler)' 에러 해결 (6) | 2024.09.18 |
[Flutter] 자주 사용하는 SnackBar Flutter 코드 템플릿 (0) | 2024.08.20 |
[Flutter] Flutter에서 "000-0000-0000" 형식으로 자동 하이픈(-) 추가되는 TextFormField 만들기 (0) | 2024.08.19 |
[flutter] linearGradient opacity 조절하여 일부 투명하게 만들기 (0) | 2024.01.15 |