找不到AudioUnit框架 [英] AudioUnit framework not found

查看:442
本文介绍了找不到AudioUnit框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现一个基于音频的应用程序,因为我需要播放应用程序音频和ipod auido。当我尝试运行我的应用程序时,我收到一个错误,例如,

I am implementing an audio based application, in that I need to play both application audio and ipod auido. When I try to run my application I am getting an error like,

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

我的视图控制器代码如下,

my view controller code is as follows,

.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

.m文件:

- (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,

FrameWorks I am using,

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

请你们看看它,让我知道,我错过了什么。

Can you guys please take a look at it and let me know, what I am missing.

提前致谢,
Chandra。

Thanks in advance, Chandra.

推荐答案

在我的例如,通过添加Accelerate.framework,除了AudioToolbox.framework和CoreAudio.framework之外,该建筑还成功了。您可能会发现也很有帮助。

In my case, by adding Accelerate.framework, besides the AudioToolbox.framework and CoreAudio.framework, the building succeeded. You may find this helpful as well.

这篇关于找不到AudioUnit框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆