swiftavaudioplayernsurlmainbundle

can't get url to work in swift


var url :NSURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("MTNSoundTrack", ofType: "aif")!)!

The name of my file and the type are double checked, but still it does not work I'm trying to play a background song in swift spriteKit


Solution

  • The problem was that the sound was not part of the target so i simply added it

    i took this post as a reference: Adding files to separate targets in Xcode 4