Reputation: 9279
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?
Upvotes: 2
Views: 4993
Reputation: 3401
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.
Upvotes: 7
Reputation: 1178
You should add the following at the top of your class
import AVFoundation
and make sure AVFoundation is in your "Link Binary with Libraries"
Upvotes: 6