Reputation: 1499
error;
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)
code i am using:
- (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;
}
(from https://devforums.apple.com/thread/90684?start=0&tstart=0 and this app was developed and works fine under ios 5.0, but crashes under ios 4.3 and How do I get my AVPlayer to play while app is in background?)
finally my plist:
what is the issue? in my header of appdelegate:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, AVAudioPlayerDelegate> {
}
seems that everything is imported. What am I doing incorrectly?
Upvotes: 1
Views: 1305
Reputation: 1499
This is how I got it to play audio in the background:
// Allow to play in background
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
also this fixed the above bug:
Add the AudioToolbox and AVFoundation frameworks to your project by Right-Cliking on Frameworks -> Add -> Existing Frameworks
Upvotes: 2