Ios Xcode:架构x86_64的未定义符号_OBJC“U类”AVPlayer“;

Ios Xcode:架构x86_64的未定义符号_OBJC“U类”AVPlayer“;,ios,objective-c,xcode,Ios,Objective C,Xcode,我尝试在我的应用程序中使用AVPlayer,我制作了一个测试应用程序,它工作得很好,但是当我尝试在我的真实应用程序中实现相同的AVPlayer时,它崩溃了,出现以下两个错误: 这是LiveViewController.h: #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface LiveViewController : UIViewController<AVAudioPla

我尝试在我的应用程序中使用
AVPlayer
,我制作了一个测试应用程序,它工作得很好,但是当我尝试在我的真实应用程序中实现相同的
AVPlayer
时,它崩溃了,出现以下两个错误:

这是LiveViewController.h:

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

@interface LiveViewController : UIViewController<AVAudioPlayerDelegate>
@property (strong, nonatomic) AVPlayer *audioPlayer;
@property (strong, nonatomic) IBOutlet UIButton *playPauseBtn;
- (IBAction)playAudio:(id)sender;
@end
这些错误是什么?我如何修复它们


注意:我搜索了这些错误,但没有找到解决方案。

解决方案:将
AVFoundation.framework
添加到项目的构建阶段


希望这能有所帮助。

只需将
AVKit.framework
与构建阶段的库链接在二进制文件中即可


转到>>构建阶段。>>用库链接二进制文件>>添加AVKit.framework

您是否已将AVFoundation.framework添加到项目的构建阶段?@AlexanderTkachenko我已将其导入头文件中,这还不够吗?不,请检查它是否已添加到构建阶段。您是对的,我忘了查找,它成功了:)太好了:)祝您使用AVFoundation好运)
#import "LiveViewController.h"

@interface LiveViewController ()

@end

@implementation LiveViewController
NSURL *urlStream;

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString *urlAddress = @"http://198.178.123.23:8662/stream/1/;listen.mp3";
    urlStream = [NSURL URLWithString:urlAddress];
    self.audioPlayer = [AVPlayer playerWithURL:urlStream];
    
    NSError *error;
    
    if (error)
    {
        NSLog(@"Error in audioPlayer: %@",
              [error localizedDescription]);
    } else {
        [_audioPlayer prepareForInterfaceBuilder];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)playAudio:(id)sender {
    if(self.audioPlayer.rate > 0 && self.audioPlayer.error == nil){
        [self.audioPlayer pause];
        NSLog(@"Hello there, trying to stop playing!");
        [self.playPauseBtn setImage:[UIImage imageNamed:@"play_button"]  forState:UIControlStateNormal];
    }else{
        self.audioPlayer = [AVPlayer playerWithURL:urlStream];
        [self.audioPlayer play];
        NSLog(@"Hello there, trying to play!");
        [self.playPauseBtn setImage:[UIImage imageNamed:@"pause_button"] forState:UIControlStateNormal];
    }
}

-(void)audioPlayerDidFinishPlaying:
(AVAudioPlayer *)player successfully:(BOOL)flag
{
}

-(void)audioPlayerDecodeErrorDidOccur:
(AVAudioPlayer *)player error:(NSError *)error
{
}

-(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
{
}

-(void)audioPlayerEndInterruption:(AVAudioPlayer *)player
{
}

@end