Платформа AudioUnit не найдена

Я реализую приложение на основе аудио, в котором мне нужно воспроизводить как аудио приложения, так и ipod auido. Когда я пытаюсь запустить свое приложение, я получаю сообщение об ошибке, например

ld: framework not found AudioUnit
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

мой код контроллера представления выглядит следующим образом:

.h файл:

 #import <UIKit/UIKit.h>
 #import <MediaPlayer/MediaPlayer.h>
 #import <AudioToolbox/AudioToolbox.h>
 #import <AVFoundation/AVFoundation.h>


 @interface AudioViewController : UIViewController     <AVAudioPlayerDelegate,MPMediaPickerControllerDelegate>
{
     UIButton *musicButton;
     UIButton *soundButton;
     AVAudioPlayer *audioPlayer;
     MPMusicPlayerController *musicPlayerController;
}
@property (nonatomic, retain)  UIButton *musicButton;
@property (nonatomic, retain)  UIButton *soundButton;
@property (nonatomic, retain) MPMusicPlayerController *musicPlayerController;

- (void)musicAction;
- (void)soundAction;

@end

.м файл:

- (id)init {
    if ((self = [super init])) 
   {
         // Custom initialization
       }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];


    musicButton=[[UIButton alloc]initWithFrame:CGRectMake(10,250 ,100, 40)];
    musicButton.backgroundColor=[UIColor blueColor];
    [musicButton setTitle:@"Next" forState:UIControlStateNormal];
    [musicButton addTarget:self action:@selector(musicAction)   forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:musicButton];
    [musicButton release];

    soundButton=[[UIButton alloc]initWithFrame:CGRectMake(210,250 ,100, 40)];
    soundButton.backgroundColor=[UIColor blueColor];
    [soundButton setTitle:@"Pre" forState:UIControlStateNormal];
    [soundButton addTarget:self action:@selector(soundAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:soundButton];
    [soundButton release];

    //Setup our Audio Session
    OSStatus status = AudioSessionInitialize(NULL, NULL, NULL, NULL);    
    //We want our audio to play if the screen is locked or the mute switch is on
    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
    status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory);
    //We want our audio to mix with other app's audio
    UInt32 shouldMix = true;
    status = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof (shouldMix), &shouldMix);
    //Enable "ducking" of the iPod volume level while our sounds are playing
    UInt32 shouldDuck = true;
    AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(shouldDuck), &shouldDuck);
    //Activate our audio session
    AudioSessionSetActive(YES);

    //Setup the Music Player to access the iPod music library
    self.musicPlayerController = [MPMusicPlayerController applicationMusicPlayer];
    [self.musicPlayerController setShuffleMode: MPMusicShuffleModeSongs];
    [self.musicPlayerController setRepeatMode: MPMusicRepeatModeNone];
    [self.musicPlayerController setQueueWithQuery:[MPMediaQuery songsQuery]];

    //Setup a AVAudioPlayer sound to overlay against the Music Player audio
    NSURL *soundURL = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"overlay" ofType:@"mp3"]];
    NSError *error = nil;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error: &error];
    if (!audioPlayer)
    {
        NSLog(@"Could not create audio effect player: %@", [error localizedDescription]);
    }
    [audioPlayer prepareToPlay];
}



- (void)musicAction
{
    if (self.musicPlayerController.playbackState == MPMusicPlaybackStatePlaying)
    {
        [self.musicPlayerController pause];
    }
    else if (self.musicPlayerController.playbackState == MPMusicPlaybackStateStopped
         || self.musicPlayerController.playbackState == MPMusicPlaybackStatePaused)
    {
        [self.musicPlayerController play];
    }
}
- (void)soundAction
{
    if (audioPlayer.playing)
    {
        [audioPlayer pause];
    }
    else
    {
        [audioPlayer play];
    }

}
- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}



- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Я использую FrameWorks,

1. AuidoUnit.framework.
2. AVFoundation.framework.
3. MediaPlayer.framework.
4. UIKit.framework.
5. Foundation.framework.
6. CoreGraphics.framework.
7. CoreData.framework.

Не могли бы вы, ребята, взглянуть на это и дайте мне знать, что мне не хватает.

Заранее спасибо, Чандра.


person ChandraSekhar    schedule 24.06.2011    source источник


Ответы (2)


В моем случае, добавив Accelerate.framework, помимо AudioToolbox.framework и CoreAudio.framework, сборка прошла успешно. Вы также можете найти это полезным.

person tidaktahu    schedule 23.04.2013

Попробуйте добавить CoreAudio.framework и AudioToolbox.framework в список фреймворков.

А также удалить AudioUnit.framework

person Nik Reiman    schedule 27.06.2011
comment
Для меня это не сработало. У меня также есть AudioUnit.framework. На самом деле, если я удалю любой из этих фреймворков, я получу много ошибок связывания. Но если у меня их три, я получаю единственную ошибку связывания «Framework not found AudioUnit». Любая идея, что я делаю неправильно? Кто-нибудь понимает, почему эта ошибка появляется в первую очередь? - person Emmanuel; 19.04.2012
comment
Я использую Xcode 4.2.1, компилирующий SDK 4.3. Тем не менее, я избавился от проблемы, добавив ряд библиотек. Не уверен, что из-за чего проблема исчезла. - person Emmanuel; 20.04.2012
comment
@ Эммануэль, ты должен перепроверить, чтобы я мог обновить свой ответ :) - person Nik Reiman; 23.04.2012
comment
Я просто не понимаю, почему в сообщении об ошибке написано AudioUnit. Отсутствующая библиотека является внутренней. Компилятор врёт. - person Emmanuel; 23.04.2012
comment
@Emmanuel (или любой, у кого такая же проблема), см. здесь: stackoverflow.com/a/1756684/179015 - person Ross; 03.10.2012
comment
@Ross: Как я уже говорил, я пробовал это и другие комбинации фреймворков, связанных со звуком, и это не помогло. Наконец, мне пришлось добавить еще одну библиотеку, не связанную со звуком. Я подозреваю, что компилятор просто сильно запутался. - person Emmanuel; 06.10.2012