Maybe your wav file wasn't properly copied into Xcode (we see it in the navigator but the Bundle doesn't see it and returns nil). Oh and you should use `Bundle.main.url` instead of `Bundle.main.path`. And definitely learn about optionals, it's important.
– Eric AyaApr 23 '18 at 16:14
It's because you are trying to force unwrap the result of Bundle.main.url. ie the URL or the file is not found on the location specified. Try to use guard let of if let statements instead of force unwrapping. If a value is not in the nullable result and tries to force unwrap will crash the app.
– BXVApr 23 '18 at 16:24
@BXV Force unwrapping paths / urls in the bundle is even pretty welcome because it discovers a **design** error (checkbox *Target Membership* not checked or file name / extension misspelled). If everything is set up correctly the code **must not** crash because the files in the bundle are required to exist while the project is built.
– vadianApr 23 '18 at 16:56