Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAudioSession unknown

Tags:

ios

sprite-kit

I'm, trying to use AVAudioSession in my Swift SpriteKit app. I am getting weird "undeclared type" problems. For instance...

import AVFoundation
var audioSession:AVAudioSession {
    return AVAudioSession.sharedInstance()
}

This returns an error on the first instance of AVAudioSession,Use of undeclared type 'AVAudioSession'. Later in my code I have this line...

import AVFoundation
    override func didMoveToView(view: SKView) {
        var titleError:NSError?
        audioSession.setCategory(AVAudioSessionCategoryPlayback, error: &error)
...

Which returns the same error on AVAudioSessionCategoryPlayback. Did this stuff move in recent versions of Swift/Xcode?

like image 703
Maury Markowitz Avatar asked Dec 07 '25 03:12

Maury Markowitz


1 Answers

OK this is old and I'm sure you've solved it by now, but I just ran across the same error. The issue was that I was building for Mac while AVAudioSession is (currently) only available for iOS.

Source: https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/

like image 166
John Scalo Avatar answered Dec 08 '25 17:12

John Scalo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!