'opencv2/opencv.hpp' file not found in Xcode - ios

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:
'opencv2/opencv.hpp' file not found
hpp file in imported framework is not found by XCode
Xcode can't find source files
'opencv2/opencv.hpp' file not found in my private pod
opencv2/opencv.hpp file not found in Xcode (note this is different than #1)
https://github.com/opencv/opencv/issues/5989
https://github.com/kylemcdonald/ofxCv/issues/167
https://forums.xilinx.com/t5/Vivado-High-Level-Synthesis-HLS/Cannot-find-quot-opencv2-opencv-hpp-quot/td-p/478368
https://groups.google.com/forum/#!topic/caffe-users/Poteul9Rz20
http://answers.opencv.org/question/34066/framework-not-found-opencv/
https://github.com/iMicknl/cordova-plugin-openalpr/issues/12
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.

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

Related

Cannot find 'FirebaseApp' in scope - Xcode Swift

I am a beginner in Xcode, and I have just installed the Firebase framework with CocoaPods. When I import the framework, I want to add the line "FirebaseApp.configure()" but when I add it, Xcode gives me an error : "Cannot find 'FirebaseApp' in scope". How can I solve this error?
I already tried to re-install the framework !
enter image description here
I believe you have opened the wrong project. Things you can do to verify is to
Check if the pods have been added. For this check the root directory in Finder and see if you have a folder called Pods, or check if a folder named Pods can be seen in your project within XCode. If not open terminal go to your project directory and type pod install
After you have verified that the pods have been installed, open the KeKonMange.xcworkspace instead of the KeKonMange.xcodeproj from your finder directory (.xcworkspace is the white icon, while .xcodeproj is the blue one. example can be found below)
If you can't resolve your problem, comment below
I don't know if this helps but when I tried to launch the project, another error appeared: "Could not build Objective-C module 'Firebase'"... Maybe it has something to do with...?
Image of code : https://i.stack.imgur.com/bgkSz.png

Xcode 7.3.1 - Can't properly setup AWS

A year ago I had a project where I was using AWS. I forget exactly how it worked but it involved a BridgingHeader and no use of Frameworks.
I came back to this project today and none of the AWS stuff was working. I deleted all AWS/pod related files, got rid of the BridgingHeader reliance, cleaned the project, and proceeded to follow the pod-based instructions here:
http://docs.aws.amazon.com/mobile/sdkforios/developerguide/setup.html
However, the project still doesn't recognize any of the AWS libraries (getting the error "Use of unresolved identifier AWS...").
I saw a post by someone that suggested simply putting "import Framework" at the top of the files that use that Framework, but this doesn't work (it doesn't recognize AWSS3 when I put "import AWSS3", for example).
Then I saw advice that suggested figuring out the correct "Framework/Header/Library Search Paths" and so I created a brand new project, copied the podfile, and ran pod install. In this new project I am getting the error:
ld: warning: directory not found for option
'-F/Users/username/Library/Developer/Xcode/DerivedData/TestProj-gmhzshcpuyuvaffaocakhunyepaw/Build/Products/Debug-iphonesimulator/AWSAutoScaling'
for each of the AWS libraries.
When I go into the target build settings, I see that the Framework Search Paths have strings relating to the AWS libraries, but when I delete them I then get the error "ld: Framework not found AWSAutoScaling".
I tried giving the direct path to the respective folders but I get the same error.
I fixed the problem by opening the .xcworkspace file instead of the the .xcodeproj file.

Xcode subproject cannot find its own header files

I have an sdk that is added to my project as a subproject in xcode. My main project's classes can import all the header files successfully into the code by using
#import "Filename.h"
because I added the sdk directory to my Header Search paths in the build settings of my main project.
However, the problem is that the classes of my sdk can't successfully import each other unless they are in the same directory. In my case, this is a problem because my sdk has folders within it with header files that the files in the main sdk folder want to import. As a result, I receive the error:
'Filename.h' cannot be found
when files in the main sdk folder try to import header files nested in deeper folders in the sdk. When I tried to move all the files into the main directory (I'm fine with sacrificing organization for functionality), the original error remained and I got two more errors:
clang: error: no such file or directory: '/Users/.../MainProjectFolder/SDKFolder/NestedFolder/Filename.m'
clang: error: no input files
It seems to know where to look for the files but the other files still can't access it.
Does anyone have any ideas to help?
Thanks, any help is appreciated!

Google Analytics linker error. library not found for -lGGLAnalytics

I have just added Google Analytics to my pods like this:
pod 'Google/Analytics'
just like GA documentation suggests. Now my project won't link. It says:
library not found for -lGGLAnalytics
Did anyone ever encounter this? Thanks
I got the same error. Solved by reseting LIBRARY_SEARCH_PATHS to default value.
Select your target and navigate to Build Settings. Under Search Paths select Library Search Paths and reset it to default by pressing backspace.
In result, the value for Library Search Paths should change from blank:
to default:
Diff in .pbxproj just removes the empty value:
I'm using pods version0.39.0, Xcode 7.2.
In my case the solution was remove all but $(inherited) in Target -> Build Settings -> Other linker flags
Then of course clean and build!
I ran into this and had a very strange cause and different solution from the above, so I figured maybe this might help someone else who shows up here.
I had a working project in my normal directory and I save it to an SVN code repo. I needed to step back to a previous version for something, so I checked out a new copy from SVN and updated it back to the revision I needed.
Then I started getting the library not found for -lGGLAnalytics error.
It turns out that SVN doesn't really like it when you check-in *.a files and it ignores them by default. So my SVN repo had all of the Google Pod code but was missing the libGGLAnalytics.a files and a couple of other .a files.
How I solved it:
I copied the Pods/Google and Pods/GoogleAnalytics directories over from my real project. Then I did a pod install from the command line which updated my project files to reference those files that were previously missing.
I did a Build Clean and all fixed.

Facebook iOS SDK 3.1 from Github missing FacebookSDK.framework

I want to use Facebook SDK on XCode 4.5 for integration with iOS6.
I read this tutorial. I was using this .dmg package to install the library but I need to track and read the implementation of some methods, so I noticed that there is a repo on Github with the current source code.
My problem is that I don't know how to install this properly as with the package .dmg. Any ideas on how to do it? I tried to just import the src folder and reference the whole project but I'm having a lot of issues, warnings and errors.
Update
I had to do this again, so now I made it work. Here is what I did:
I tried both ways, building the source code (1) and importing the files directly(2). On the first scenario it was easy, on the root folder of Github repo just run:
sudo scripts/build_framework.sh
You will get the files needed, the same that you get when installing with .pkg. But I needed to track the functions, so I tried to importing the files.
First I added the src folders from the Github repo on my project. I had an issue with duplicated definitions on every file. The problem was on my Build Settings (BS), I was still referencing to the .pkg install directory of Facebook so I had the files duplicated. I removed every reference to that folder on BS and then added the files.
After that, on the files that imported the Facebook files I got:
Undefined symbols for architecture i386
When I copied the files to XCode, the .m files where not automatically added to the Build Phases / Compile Sources. I added them manually and imported FBConnect.h on my files.
Hope it helps some one with the same issue.
If you include the FacebookSDK via git, you will need to build the framework. Run the following command from within the FacebookSDK directory:
scripts/build_framework.sh
Then, FacebookSDK.framework will appear in FacebookSDK/build
Add the entire src folder to your project. Import FBConnect.h in any class where you want to use Facebook. The connect class imports the rest of the necessary classes.
#import "FBConnect.h"

Resources