如何加载声音资源? URLForResource returns 无

How do I load sound resource? URLForResource returns nil

我一直在关注 this 教程。这行代码returns nil...

let url = NSBundle.mainBundle().URLForResource(filename as String, withExtension: "caf")

这是我的资源...

这是我的构建阶段...

NSBundle(forClass: self.dynamicType) 并没有改善这种情况。

当我将声音文件拖到项目而不是项目的资产目录中时,代码有效。我猜后者的项目是由 id 而不是文件名和类型引用的。

我还需要将声音文件添加到 "Build Phases" 中的 "Copy Bundle Resources" 部分。