iOS背景音频链接器错误
问题描述:
错误;iOS背景音频链接器错误
undefined symbols for architecture i386:
"_AudioSessionSetProperty", referenced from:
-[AppDelegate applicationDidFinishLaunching:] in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
代码我使用:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Set AudioSession
NSError *sessionError = nil;
[[AVAudioSession sharedInstance] setDelegate:self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
/* Pick any one of them */
// 1. Overriding the output audio route
//UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
//AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride);
// 2. Changing the default output audio route
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
return YES;
}
(从https://devforums.apple.com/thread/90684?start=0&tstart=0和this app was developed and works fine under ios 5.0, but crashes under ios 4.3和How do I get my AVPlayer to play while app is in background?)
终于我的plist:
问题是什么?在我的appdelegate的标题中:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, AVAudioPlayerDelegate> {
}
似乎是一切都导入。我做错了什么?
答
这是我得到了它在后台播放音频:
// Allow to play in background
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
也是这个固定的上述错误:
通过右键Cliking添加AudioToolbox和AVFoundation框架到您的项目在框架 - >添加 - >现有框架
您是否将AudioToolbox添加到应用程序中?是,然后再删除并再次删除 通过在框架上右键单击添加AudioToolbox和AVFoundation框架到您的项目 - >添加 - >现有框架 – iSpark 2013-03-16 10:42:39
是的,我相信我没有 – stackOverFlew 2013-03-16 10:50:00
它还在吗? – iSpark 2013-03-16 10:51:08