Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks
imdp6 opened this issue Sep 21, 2021 · 6 comments

Comments

@imdp6
Copy link

imdp6 commented Sep 21, 2021

✔️ Issue Checklist

✍🏻 Issue Description

💻 Environment

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

imdp6 commented Sep 21, 2021

/// 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()
    }
}

}
这样不报错了

@anilsozeri
Copy link

I had same problem.

@VisroliyaHimanshu
Copy link

I had same problem too.

@jopache
Copy link
Contributor

jopache commented Oct 21, 2021

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

@sergeymild
Copy link

The sane issue

@flyweights
Copy link

大佬,没空处理一下?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants