Using WatchKit, when trying
let asset = NSDataAsset(name:"ASSET-NAME")
XCode throws the following error Use of unresolved identifier 'NSDataAsset'
So how do I get a (sound) file from the asset catalog using WatchKit?
According to another thread you can get your audio file with
let filePath = Bundle.main.path(forResource: "fileName", ofType: "m4a")!
let fileUrl = URL(fileURLWithPath: filePath)
let asset = WKAudioFileAsset(URL: fileUrl)
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