AVAudioPlayer崩溃模拟器,但在设备上运行

问题描述:

我有一个应用程序播放声音剪辑作为提示音。在实际的设备上一切都很好,但它在模拟器上崩溃。AVAudioPlayer崩溃模拟器,但在设备上运行

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4a"]; 
NSString *expandedFilePath = [filePath stringByExpandingTildeInPath]; 
NSURL *fileURL = [NSURL fileURLWithPath:expandedFilePath]; 
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]; 
[self.player play]; 

我找到了许多与模拟器的问题张贴的一些建议使用stringByExpandingTildeInPath但没什么区别。我已经尝试过mp3,m4a和wav文件,并且它们都以相同的方式运行。在6.0和6.1模拟器我没有得到一个错误,但是当我在5.1模拟器我得到了在控制台下面的错误运行:

2013-04-04 10:57:03.682 MyAppName[51504:1b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
in /System/Library/Frameworks/Security.framework/Versions/A/Security 

我也许可以用这个活,只要有ISN”对于可能在真实设备上导致问题的代码有根本错误。

+0

在使用Xcode 6.1 GM的iOS8中遇到同样的问题。你有没有在这个问题上提出错误? – 2014-10-01 21:43:14

模拟器很有趣AVAudioPlayer你应该在真实设备上测试你的代码,但你发布的内容看起来不错。