未找到 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
.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,
1. AuidoUnit.framework.
2. AVFoundation.framework.
3. MediaPlayer.framework.
4. UIKit.framework.
5. Foundation.framework.
6. CoreGraphics.framework.
7. CoreData.framework.
你们能看一下它并让我知道,什么我失踪了。
提前致谢, 钱德拉。
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 file:
#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 File:
- (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 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.
Thanks in advance,
Chandra.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将
CoreAudio.framework
和AudioToolbox.framework
添加到您的框架列表中。并删除 AudioUnit.framework
Try adding
CoreAudio.framework
andAudioToolbox.framework
to your list of Frameworks.And also remove AudioUnit.framework
就我而言,除了 AudioToolbox.framework 和 CoreAudio.framework 之外,还添加了 Accelerate.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.