본문 바로가기
프로그래밍/Flutter <Dart>

[Flutter] iOS 18 Type 'UIApplication' does not conform to protocol 'Launcher' 에러 해결

by TaeGyeong Lee 2024. 9. 18.

개요 

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

 

참고 자료

 

[url_launcher] `'UIApplication' does not conform to protocol 'Launcher'` with Xcode16 beta3 · Issue #151467 · flutter/flutter

What package does this bug report belong to? url_launcher What target platforms are you seeing this bug on? iOS Have you already upgraded your packages? Yes Dependency versions pubspec.lock url_lau...

github.com

 

url_launcher_ios | Flutter package

iOS implementation of the url_launcher plugin.

pub.dev

 

[ios]Fix compile error when conforming UIApplication to Launcher due … · flutter/packages@33caf1d

…to MainActor annotation (#7100) iOS 18 Beta 3 added `@MainActor @Sendable` for openURL's completion handler: ``` @available(iOS 10.0, *) open func open(_ url: URL, options: [UIA...

github.com