iOS12 lost function to set AVAudioSession category on iOS 9

Originator:alessandro.calzavara
Number:rdar://42382075 Date Originated:Thu, 19 Jul 2018
Status:Open Resolved:
Product:iOS Product Version:12 beta
Classification:Serious Bug Reproducible:Always
 
Area:
AVFoundation

Summary:

In Xcode 9 I can set the audio session category with this function

```
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
```

but on Xcode 10/iOS12/swift 4.2 that method has disappeared from Swift. It's still available on Objc but not anymore on Swift.

It's not possible to configure the audio session category on iOS 9.

Steps to Reproduce:

Type these instructions on a project that support iOS9 and newer

 do {
            if #available(iOS 11.0, *) {
                try audioSession.setCategory(.playback, mode: .default, policy: .longForm, options: [])
            } else if #available(iOS 10.0, *) {
                try audioSession.setCategory(.playback, mode: .default, options: [])
            } else {
                // Compiler error: 'setCategory' is unavailable in Swift
                try audioSession.setCategory(AVAudioSession.Category.playback)
            }
        } catch let error {
            print("Unable to configure audio sesson category: \(error)")
        }

The code will not compile.

Expected Results:

That instruction should be STILL accessible and usable in swift and the app should compile.

Actual Results:

Compiler report the following error

'setCategory' is unavailable in Swift

Version/Build:

Version 10.0 beta 4 (10L213o)
iOS 12, Swift 4.2

Configuration:

Nothing special

Comments

Duplicated

Original ID 42023905

By alessandro.calzavara at July 23, 2018, 12:46 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!