PopMenu icon indicating copy to clipboard operation
PopMenu copied to clipboard

Xcode 13.0 Enum cases with associated values cannot be marked potentially unavailable with '@available'

Open imdp6 opened this issue 3 years ago • 6 comments

✔️ Issue Checklist

✍🏻 Issue Description

💻 Environment

  • iOS Version: [iOS VERSION]
  • Xcode Version: [XCODE VERSION]
  • Device(s): [INSERT DEVICE(S) HERE]
  • Simulator?: ☑️ or ❌

imdp6 avatar Sep 21 '21 07:09 imdp6

/// Haptic Generator Helper. @available(iOS 10.0, *) public enum Haptic {

/// Impact style.
case impact(UIImpactFeedbackGenerator.FeedbackStyle)

/// Notification style.
case notification(UINotificationFeedbackGenerator.FeedbackType)

/// Selection style.
case selection

/// Trigger haptic generator.
public func generate() {
    
    switch self {
    case .impact(let style):
        let generator = UIImpactFeedbackGenerator(style: style)
        generator.prepare()
        generator.impactOccurred()
    case .notification(let type):
        let generator = UINotificationFeedbackGenerator()
        generator.prepare()
        generator.notificationOccurred(type)
    case .selection:
        let generator = UISelectionFeedbackGenerator()
        generator.prepare()
        generator.selectionChanged()
    }
}

} 这样不报错了

imdp6 avatar Sep 21 '21 09:09 imdp6

I had same problem.

anilsozeri avatar Sep 29 '21 09:09 anilsozeri

I had same problem too.

VisroliyaHimanshu avatar Oct 01 '21 13:10 VisroliyaHimanshu

Try adding this to your pod file to alleviate that issue. This is probably a little brute force-ish but it will set minimum deployment target on all your projects referenced pods to 10.0, at which point the @available error is no longer an issue as those types are now always available (this project is set to 9.0)

post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0' end end end

jopache avatar Oct 21 '21 17:10 jopache

The sane issue

sergeymild avatar Oct 30 '21 10:10 sergeymild

大佬,没空处理一下?

flyweights avatar Apr 22 '22 03:04 flyweights