I Can't find setCategory() function from AVAudioSession in swift 4.2 with Xcode 10.0 beta

Hi.

I'm testing some project in Swift 4.2 with Xcode 10.0 beta.

The Minimum iOS target is iOS 9.0 in my project.

But, I couldn't find the appropriate function for the function that can use in the iOS 9.0 target: func setCategory(_ category: String, with options: AVAudioSessionCategoryOptions = []) throws.

If minimum target is higher than iOS 10.0, there is alternatives:

@available(iOS 10.0, *)

open func setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode, options: AVAudioSession.CategoryOptions = []) throws

@available(iOS 11.0, *)

open func setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode, policy: AVAudioSession.RouteSharingPolicy, options: AVAudioSession.CategoryOptions = []) throws


I don't know it is Swift fault or Xcode fault.

So, I wonder the problem will be fixed or... other solution?


Thank you.

Accepted Reply

Yes, "setCategory(_:options:)" is missing from the Swift SDK overlay, for some reason. You should file a bug report.


If you really need to set category options, I guess the workaround would be to use an Obj-C helper function.

Replies

The function "setCategory(_:mode:options:)setCategory(_:mode:options:)" was new in iOS 10, so you can't use it if you're targeting iOS 9. However, you can still use "setCategory(_:options:)" followed by "setMode(_:)" to achieve the same effect.

Thank you for your answer.


I couldn't find "setCategory(_:options:)" followed by "setMode(_:)"

Neither Xcode 9.4.1 or Xcode 10.0 Beta 4.

In Xcode 10.0 Beta 4(or Swift 4.2), only two functions of original question content exist.


Actually, there is some functions available in iOS 9 environment in Objective-C.

Yes, "setCategory(_:options:)" is missing from the Swift SDK overlay, for some reason. You should file a bug report.


If you really need to set category options, I guess the workaround would be to use an Obj-C helper function.

Ok, I wonder if it is bug or my mistake.

Thank you for your answer, I will file a bug report.

Thanks a lot.