sparrowcode / AlertKit

Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.

Home Page:https://sparrowcode.io/frameworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xcode 13 beta 3: 'shared' is unavailable in application extensions for iOS

gongzhang opened this issue · comments

Describe the bug
The package won't compile in latest Xcode 13.0 beta 3 using SPM. It seems that the latest compiler requires us to mark present(...) as @available(iOSApplicationExtension, unavailable) explicitly since UIApplication.shared is unavailable in extension target. Even though we don't have any extension target.

// SPAlertView.swift

    open func present(duration: TimeInterval = SPAlertConfiguration.duration, haptic: SPAlertHaptic = .success, completion: (() -> Void)? = nil) {
        
        if self.presentWindow == nil {
            self.presentWindow = UIApplication.shared.keyWindow // <=== 👀 Error: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.... 'shared' has been explicitly marked unavailable here (UIKit.UIApplication)
        }
        
        guard let window = self.presentWindow else { return }
        
        window.addSubview(self)
        
        // Prepare for present
        // ...
        

To Reproduce

  1. Create a new iOS project in Xcode, and add SPAlert in Package Dependencies.
  2. Add SPAlert library to iOS target.
  3. Compile.

Expected behavior
No error like in Xcode 12.

Smartphone (please complete the following information):

  • Xcode version 13.0 beta 3
  • SPAlert version 3.2.4
  • Installed via SPM

Thanks for it, in beta I think no way using key window. I going to check it and find any other solution. Soon let you know here.

Having the same issue :(

Fixed in 3.3.0, please, update. If have any problem after update version, let me know please.