Swift 4 - OpenCV 3.2 on Xcode 9.0 beta 2

I am actually trying to use OpenCV with ARKit to build an AR application. For the last 6 hours I have tried everything to install OpenCV on my Swift project, but that seems to be impossible.
I followed this tutorial on Medium and I ended up with 3 new framework files: OpenCVWrapper.h and OpenCVWrapper.mm for the wrapper and LittleFarm -Bridging-Header.h for the bridge header, here is the code:

OpenCVWrapper.h

#import <Foundation/Foundation.h>
#import <stdio.h>
@interface OpenCVWrapper : NSObject

- (void) isItWorking;
@end

      

OpenCVWrapper.mm

#import "OpenCVWrapper.h"
#import <opencv2/opencv.hpp>

@implementation OpenCVWrapper

    using namespace std;
    - (void) isItWorking {
        printf("Hey");
    }
    @end

      

LittleFarm-Bridging-header.h

#import "OpenCVWrapper.h"

      


But then I get this error: "opencv2 / opencv.hpp" not found.
I tried to figure out what the problem is and I set Framework_Search_Path to $ (PROJECT_DIR). It doesn't change anything, and if I try to comment out the related line, I get this error:
ld: framework not found opencv2
clang: error: linker command failed with exit code 1 (use -v to see the call)


Edit: At build step > Binary link with Librairies opencv2 view is here.

Thanks in advance for your help!

+3


source to share


1 answer


I finally managed to fix my problem with a lot of help from hoang Cap .



  • First, instead of dragging the openCV framework, I install it using Cocoapods
  • Please note that version 3.2 generates some problems, 3.1.0.1 works fine.

    pod 'OpenCV', '~> 3.1.0.1'

  • Deactivate bitcode for both the target and your project.

+3


source







All Articles