3

I'm using the npm package react-native-perspective-image-cropper and it requires me to install opencv2. In the package's file, it imports opencv2, with the following:

#import <opencv2/opencv.hpp>

And no matter what I do I keep getting the following error:

'opencv2/opencv.hpp' file not found

I've read almost every article and question online and I just can't figure it out. I followed the installation steps provided in the article:

  • I downloaded opencv2.framework from here and moved the file opencv2.framework into my ios folder.
  • Then in XCode, I right clicked on my project, choose add files and selected opencv2.framework

This is when I first got the error. I tried the following fixes to no avail:

  • I tried to reinstall and relink the npm package that I was trying to use (I'm not using cocoa pods).
  • I tried changing the import to be #import "opencv2/opencv.hpp" (replacing the brackets with parenthesis.
  • I tried adding opencv2.framework to Link Binary with Library under Build Phases
  • I tried adding opencv2.framework to Copy Bundle Resources under Build Phases
  • I changed Always Search User Paths (Deprecated) to yes
  • I added a Framework Search Path of:
    • $(inherited)
    • $(PROJECT_DIR)
    • $(PROJECT_DIR)/opencv2.framework
    • $(PROJECT_DIR)/./opencv2.framework
    • $(PROJECT_DIR)opencv2.framework
    • /usr/lib**
  • I added a Header Search Path of:
    • $(inherited)
    • $(PROJECT_DIR)
    • $(PROJECT_DIR)/opencv2.framework
    • $(PROJECT_DIR)/./opencv2.framework
    • $(PROJECT_DIR)opencv2.framework
    • /usr/lib**
  • I tried moving opencv2.framework under the Framework folder
  • I tried moving opencv2.framework directly under the package

I cleaned the product and rebuilt after each attempt and each attempt was attempted at least once (which you can imagine was a ton of fun).

Here are some of the sources I tried to use:

I genuinely have no clue where to look at this point. Any help would be greatly appreciated. I can also post any updates if more information would be helpful.

Eric Wiener
  • 4,929
  • 4
  • 31
  • 40

1 Answers1

2

you can maybe try cocopod https://cocoapods.org/pods/OpenCV or https://cocoapods.org/pods/OpenCV2 in my case I am not sure why I can't install OpenCV2 with cocopod but it stop giving me error after I use cocopod

KUROYUKI
  • 113
  • 4
  • 16
  • Thanks for the answer. I’ll try it out later. I ended up switching to a different library that didn’t require it. – Eric Wiener Aug 16 '18 at 13:15