plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: 'keyWindow' is deprecated

Open xunreal75 opened this issue 2 years ago • 3 comments

Platform

iOS >13.0

Plugin

share_plus

Version

4.0.8

Flutter SDK

3.0.0

Steps to reproduce

on compile with Deploymentversion 13.0 .... /flutter/.pub-cache/hosted/pub.dartlang.org/share_plus-4.0.8/ios/Classes/FLTSharePlusPlugin.m:12:44: warning: 'keyWindow' is deprecated: first deprecated in iOS 13.0 - Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes [-Wdeprecated-declarations] return [UIApplication sharedApplication].keyWindow.rootViewController; ^ In module 'UIKit' imported from .../ios/Pods/Target Support Files/share_plus/share_plus-prefix.pch:2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:135:51: note: 'keyWindow' has been explicitly marked deprecated here @property(nullable, nonatomic,readonly) UIWindow *keyWindow API_DEPRECATED("Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes", ios(2.0, 13.0));

Code Sample

No response

Logs

--

Flutter Doctor

[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-x64, locale de-DE)
    • Flutter version 3.0.2 at /Users/lars/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (vor 11 Tagen), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/lars/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 68.1.4
    • Dart plugin version 221.5787.37

[✓] Connected device (4 available)
    • TestIphone + TestWatch (mobile) • BAE4E97D-583B-4557-9CF3-25B2D6E6AAA3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • TestWatch (mobile)              • 4F71CDF8-1833-4F11-860B-3DB4A74326DC • ios            • com.apple.CoreSimulator.SimRuntime.watchOS-8-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-x64     • macOS 12.4 21F79 darwin-x64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 102.0.5005.115
   
[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

xunreal75 avatar Jun 19 '22 09:06 xunreal75

Thanks for the submission @xunreal75

Is this causing the compilation to fail, or is it just a warning?

miquelbeltran avatar Jun 20 '22 09:06 miquelbeltran

Hi, at the moment a warning on compilation with Apple Deploytarget 13. I had not tried to upload my App to Appstore

  • perhaps you can replace

static UIViewController *RootViewController() { UIWindow *mainWindow = nil; if ( @available(iOS 13.0, *) ) { mainWindow = [UIApplication sharedApplication].windows.firstObject; [mainWindow makeKeyWindow]; } else { mainWindow = [UIApplication sharedApplication].keyWindow; } return mainWindow.rootViewController }

xunreal75 avatar Jun 20 '22 16:06 xunreal75

I ignore the warning. Upload and review to AppStore are successfully finished.

xunreal75 avatar Jul 17 '22 17:07 xunreal75

Hi, my app runs at emulator, but fails when building the IPA file. Output:

{my user}/.pub-cache/hosted/pub.dartlang.org/share_plus-4.4.0/ios/Classes/FLTSharePlusPlugin.m:12:44: warning: 'keyWindow' is deprecated: first deprecated in
    iOS 13.0 - Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes [-Wdeprecated-declarations]
      return [UIApplication sharedApplication].keyWindow.rootViewController;
                                               ^
    In module 'UIKit' imported from {flutter project}/ios/Pods/Target Support Files/share_plus/share_plus-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.
    h:135:51: note: 'keyWindow' has been explicitly marked deprecated here
    @property(nullable, nonatomic,readonly) UIWindow *keyWindow API_DEPRECATED("Should not be used for applications that support multiple scenes as it returns a key window
    across all connected scenes", ios(2.0, 13.0));
                                                      ^

*I removed my project's name from the logs

stefaniamak avatar Sep 26 '22 11:09 stefaniamak

Created a PR (#1157) that will prevent the deprecation warning on iOS 13+

daniel-shuy avatar Oct 04 '22 15:10 daniel-shuy