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?
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With