简体   繁体   中英

AVAudioPlayer crashing simulator but runs on device

I have an app that plays a sound clip as an alert tone. Everything works great on an actual device, but it crashes on the simulator.

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];

I found lots of posting with simulator problems and some suggest using stringByExpandingTildeInPath but that makes no difference. I have tried mp3, m4a and wav files and all of them behave the same way. In the 6.0 and 6.1 simulators I do not get an error, but when I run it in the 5.1 simulator I get the following error in the console:

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

I can probably live with this as long as there isn't something fundamentally wrong with the code that might cause problems on a real device.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM