freshOS / KeyboardLayoutGuide

⌨️ KeyboardLayoutGuide, back from when it didn't exist.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xcode 13 beta 3 - SwiftPM - Build error: UIApplication.shared not available in iOS App Extension

klanchman opened this issue · comments

When building an app with KeyboardLayoutGuide from Swift Package Manager in Xcode 13 beta 3 that does not use app extensions, compiler errors related to API availability in app extensions are emitted.

Reproduction Steps

  • Create a new iOS project in Xcode 13 beta 3
  • Add KeyboardLayoutGuide at latest version (1.7.0) using Swift Package Manager
  • Build the app

Result: multiple errors on UIApplication.shared usage:

'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

Other Notes

This appears to be expected behavior in Xcode 13 beta 3 with Swift Package Manager, based on this Apple Developer Forums thread and this Swift forums post. The Apple engineer in the second link recommends dealing with this by marking declarations as unavailable to app extensions when they use APIs that are unavailable to app extensions.


Update: It looks like the Swift team is reconsidering how this behaves. I'll update this issue as we hear more from them.

Apple reverted this change in Xcode 13 beta 5, these errors no longer occur.