title: AVAudioPlayer not playing any sound
body: <p>I'm working on an iOS application that needs to play some sounds using the <code>AVFoundation</code> framework. The workspace structure in Xcode 4 contains two projects:</p>
  
  <ul>
  <li>Workspace
  <ul>
  <li>The application itself (main project)</li>
  <li>A utility library</li>
  </ul></li>
  </ul>
  
  <p>After building the utility library, it results in a static library which is used in the main application as a framework.</p>
  
  <p>So, when trying to play a sound inside the main application by using the code below, it works as expected.</p>
  
  <pre><code>NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
  NSString *path = [NSString stringWithFormat:@"%@/sound.mp3", resourcePath];
  
  NSURL *url = [NSURL fileURLWithPath:path];
  NSError *error = nil;
  
  AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url
                                                                      error:&amp;error];
  [audioPlayer play];
  </code></pre>
  
  <p>In contrast, when trying to play exactly the same sound (or any other) inside the utility library using the same code as above, no sound is played at all, even though error is <em>nil</em> and the <em>audioPlayer</em> property values are the right ones (number of channels, duration).</p>
  
  <p>I've made sure the <code>AVFoundation</code> framework is in both projects.</p>
  
  <p>Also, my class uses the <code>AVAudioPlayerDelegate</code> protocol and implements these two methods:</p>
  
  <pre><code>- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag;
  - (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error;
  </code></pre>
  
  <p>None of these methods is called after trying to play the sound.</p>
  
  <p>If I use the <code>AudioToolbox</code> framework instead, then it plays the sound. But I'm interested in using <code>AVFoundation</code> for several reasons.</p>
  
  <p>Any idea of what is going on? Am I missing something about <code>AVFoundation</code>? Could it be related to using <code>AVAudioPlayer</code> from inside a static library?</p>
  
  <p>Thanks in advance.</p>