I am trying to play a sound as follows:
import AVFoundation
let sound = URL(fileURLWithPath: Bundle.main.path(forResource: "audiofile", ofType: "wav")!)
var audioPlayer = AVAudioPlayer()
@IBAction func audio1(_ sender: Any) {
do {
audioPlayer = try AVAudioPlayer(contentsOf: sound)
audioPlayer.play()
} catch {
// error
}
When running in the iOS simulator this results in the following:
2019-01-08 12:29:55.438490+0800 Test App[8096:118590] Error loading /Library/Audio/Plug-Ins/HAL/NRDAudioClient.plugin/Contents/MacOS/NRDAudioClient: dlopen(/Library/Audio/Plug-Ins/HAL/NRDAudioClient.plugin/Contents/MacOS/NRDAudioClient, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/HAL/NRDAudioClient.plugin/Contents/MacOS/NRDAudioClient: mach-o, but not built for iOS simulator
2019-01-08 12:29:55.438703+0800 Test App[8096:118590] Cannot find function pointer NRDACLN_New_Instance for factory 3E9FAD07-70A8-4980-B39B-BB8B905C9872 in CFBundle/CFPlugIn 0x7fcf5b135210 (bundle, not loaded)
I haven't found any information at all on what "NRDAudioClient" is. I am using macincloud so am not sure if this error is related to a specific setup there.
Click on Product -> Clean (or CMD-Shift-K)
Or by manually cleaning the Xcode setting files:
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" rm -rf ~/Library/Developer/Xcode/DerivedData rm -rf ~/Library/Caches/com.apple.dt.Xcode
I have no idea why though. Good luck see if it helps.
Hope this works for you.