ios - xcode 说找不到 ZBarSDK.h,但是它在我的项目中

标签 ios xcode build zbar

我得到的构建错误如下:

Lexical or preprocessor issue 'ZBarSDK.h' file not found

我在我的项目下看到它,我需要做什么才能让构建找到它?

我试过将它拖到我的主项目文件夹中。

最佳答案

忘记了 ZBarSDk 这已经包含在 AVFoundation 框架工作中 用这个

在 ios 7 和更新版本上试试这个

获取二维码:

- (IBAction)Capture:(id)sender {

  isFirst=true;
 _session = [[AVCaptureSession alloc] init];
    _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    NSError *error = nil;

    _input = [AVCaptureDeviceInput deviceInputWithDevice:_device error:&error];
    if (_input) {
        [_session addInput:_input];
    } else {
        NSLog(@"Error: %@", error);
    }

    _output = [[AVCaptureMetadataOutput alloc] init];
    [_output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
    [_session addOutput:_output];

    _output.metadataObjectTypes = [_output availableMetadataObjectTypes];

    _prevLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session];
    _prevLayer.frame = self.view.bounds;
    _prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
    [self.view.layer addSublayer:_prevLayer];

    [_session startRunning];
}

读取使用它的委托(delegate)方法:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
{
    CGRect highlightViewRect = CGRectZero;
    AVMetadataMachineReadableCodeObject *barCodeObject;
    NSString *detectionString = nil;
    NSArray *barCodeTypes = @[AVMetadataObjectTypeUPCECode, AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode39Mod43Code,
            AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode93Code, AVMetadataObjectTypeCode128Code,
            AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode];

    for (AVMetadataObject *metadata in metadataObjects) {
        for (NSString *type in barCodeTypes) {
            if ([metadata.type isEqualToString:type])
            {
                barCodeObject = (AVMetadataMachineReadableCodeObject *)[_prevLayer transformedMetadataObjectForMetadataObject:(AVMetadataMachineReadableCodeObject *)metadata];
                highlightViewRect = barCodeObject.bounds;
                detectionString = [(AVMetadataMachineReadableCodeObject *)metadata stringValue];
                break;
            }
        }

        if (detectionString != nil)
        {
            if (isFirst) {
            isFirst=false;
            _label.text = detectionString;
            break;
           }
        }
        else
            _label.text = @"(none)";
    }

    _highlightView.frame = highlightViewRect;
}

关于ios - xcode 说找不到 ZBarSDK.h,但是它在我的项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30802695/

相关文章:

iOS 使用 Core Motion 计算设备速度

ios - UISplitViewController 在纵向显示细节上方的主视图

iphone - 实现模态视图 Controller 数据传输的委托(delegate)方法

c - CMake下的多个目录

android - 无法解析拆分 Gradle 构建脚本中的库类

iOS 9 通知 - 为什么在我请求权限时缺少我的应用程序名称?

iphone - 在CoreData中存储时间(小时:分钟)

ios - NSLocalizedStringFromTable 不起作用

ios - 试图在自己的 willSet 中存储属性 ''

node.js - gatsby 开发工作,但不是在同一个项目上构建