Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld: symbol(s) not found for architecture i386 Error while using AVFoundation

I'm trying to use AVFoundation Framework to create a video thumbnail. I have correctly added and imported #import <AVFoundation/AVFoundation. Here is the code for creating the thumbnail:

AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:[NSURL URLWithString:moviePath] options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.appliesPreferredTrackTransform=TRUE;
CMTime thumbTime = CMTimeMakeWithSeconds(0,30);

AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
    if (result != AVAssetImageGeneratorSucceeded) {
        NSLog(@"couldn't generate thumbnail, error:%@", error);
    }
    [imageButton setImage:[UIImage imageWithCGImage:im] forState:UIControlStateNormal];
    //UIImage *thumbImg=[UIImage imageWithCGImage:im];
};

CGSize maxSize = CGSizeMake(320, 180);
generator.maximumSize = maxSize;
[generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];

When I build this, I get the following error:

Undefined symbols for architecture i386:_CMTimeMakeWithSeconds", referenced from:
  -[photojournal generateImage] in photojournal.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've reviewed similar questions on Google and here on Stack Overflow, and the consensus seems to be to add missing files to compile sources. My question is - what are the missing files for AVFoundation? Shouldn't they all come when I import the Framework? Thanks.

like image 934
Kwame Avatar asked Dec 19 '25 09:12

Kwame


1 Answers

You need to add the Core Media framework to your project, and

#import <CoreMedia/CoreMEdia.h>

CMTime is part of the Core Media framework. I had the same error and this solved it.

like image 104
andrewmobile Avatar answered Dec 21 '25 03:12

andrewmobile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!