Skyscanner / SkyFloatingLabelTextField

A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.
Apache License 2.0
4.09k stars 540 forks source link

Compiler error 'shared' is unavailable in application extensions for iOS with SPM and Xcode 13 beta 3 #331

Open martinknabbe opened 2 years ago

martinknabbe commented 2 years ago

Report

What did you do?

Integrating SkyFloatingLabelTextField version 4.0.0 with Swift Package Manager and Xcode 13 beta 3 (13A5192i).

What did you expect to happen?

Library compiles without errors.

What happened instead?

Compiler emits error 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead. SkyFloatingLabelTextField.swift line 33

This error appears due to the changes in the linker mentioned in the Xcode release notes

Resolved in Xcode 13 Beta 3

Linking Swift packages from application extension targets or watchOS applications no longer emits unresolvable warnings about linking to libraries not safe for use in application extensions. This means that code referencing APIs annotated as unavailable for use in app extensions must now themselves be annotated as unavailable for use in application extensions, in order to allow that code to be used in both apps and app extensions. (66928265)

All libraries that use API marked as unavailable in iOS app extensions, such as UIApplication.shared, have to mark their code themself with @available(iOSApplicationExtension, unavailable) in Swift and NS_EXTENSION_UNAVAILABLE in Objective-C.

Environment

Xcode Version: 13 beta 3 (13A5192i) SkyFloatingLabelTextField Version: 4.0.0 Deployment Target: iOS 11.4 Base SDK: 15.0 Method of Integration: Swift Package Manager

martinknabbe commented 2 years ago

Not sure what the future plan is in SwiftPM, but this was reverted for now in Xcode 13 beta 5.

Swift Packages Resolved in Xcode 13 Beta 5

You don’t need to annotate code as unavailable for use in application extensions if it references APIs annotated as unavailable for use in application extensions. This reverts a requirement that Xcode 13 Beta 3 introduced. (80615922) (FB9332020)

Thread with some more details: https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333/27