'How can I use the AVAudioSEssion in a swift package when the package could be used by Macos?


import Foundation
import AVFoundation

@available(iOS 14, *)
extension AVAudioSession {

    class func set(category: AVAudioSession.Category = .playback) {
        do {
            try AVAudioSession.sharedInstance().setCategory(category)
        } catch {
            print("Audio session failed", error)
        }
    }
}

enter image description here

Even when I use the @available( attribution it doesn't work. How can I use the AVAudioSEssion in a swift package when the package could be used by Macos?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source