I installed msgpack with brew and can compile the sample code with gcc msgpacktest.c -lmsgpack in the command line. But when I add the header in test.m, a class in my iOS project and add -lmsgpack in Compile Sources of Build Phases, I still get the error msgpack.h file not found. I am a new programmer and this is confusing me. What am I missing?
You need to tell Xcode where to find the header. In Build Settings, under Search Paths, add the path under User Header Search Paths.
Related
Following the steps from React Native official tutorial, the xcode project created by "react-native init MyFirstRNProject" won't compile. It complains "React/xxxxx.h" can't be found.
After further investigation of this xcode project, I figured the "React" target contains a build phase "Copy Headers" which copies all exposed headers into a weird location:
"MyFirstRNProject/node_modules/react-native/React/build/Debug-iphonesimulator/include/React"
OK, cool, at least we got the header location. We can change the copied location to somewhere else that better than this. So whichever the project that do "#import < React/xxxxx.h >" should have above path in "Header Search Path" in build settings. Unfortunately, all projects have "Header Search Path" empty. And that's why I'm getting tons of header not found error.
OK, let's add it. Now it finds headers, but compilation still failed, see reference below:
https://github.com/facebook/react-native/issues/21482
The discussion above saying that removing the "Header Search Path" of the projects will solve the problem. But we know that without header search path, it again can't find React headers.
Just curious now, I don't think my setup is wrong, does anyone has the same issue?
I had the same problem on fresh install of Xcode 10.1
There are few steps to follow to compile the new project after react-native init appName
In Xcode, Select File -> Project/Workspace Settings. You will see a Build System option to select the Legacy Build System as shown below
Change Advanced settings, and set Build Location to Custom and change paths to Relative to Workspace and Build/ to build/Build/ as showed.
3. User Debug for command-line builds(for react-native run-ios to work properly)
Clear your project
After this manipulations(don't need set header search paths) you'll be able to build and run empty project via Xcode or CLI
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
I've got to import a Framework into my Swift project that is written in Objective C. So I've created a Bridging file and after I've added the Header files to it and compiled, my project says it cannot find them. The image below shows my Framework and you can clearly see AWController.h but it throws an error in my Bridging file when building.
The Bridging file shows in my Settings so what am I doing wrong or what have I missed? I've set my Defines Module to Yes in Build Settings and my Module Name has no spaces.
I would review the setup for AWS at their website. They even have a section that details using with Swift iOS9.
Among other things, if you are using the Frameworks manual integration, verify that step 4 is complete.
Under the Build Phases tab in your Target, click the + button on the
top left and then select New Run Script Phase. Then setup the build
phase as follows. Make sure this phase is below the Embed Frameworks
phase.:
Shell /bin/sh
bash
"${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework/strip-frameworks.sh"
Show environment variables in build log: Checked Run script only when
installing: Not checked
Input Files: Empty Output Files: Empty
You might want to install and use Carthage to make this easier. Head over to the Homebrew website then after installing homebrew you'd run brew install carthage from the command line. After that go back to the link above and follow the Carthage instructions.
Secondly, I would take another walkthrough of the Apple Documentation on Working with the bridging header files to see if any of the edge cases apply and just as a sanity check.
Third, if that doesn't work, I'd just try creating an empty Swift project and walk through the steps again using one of the techniques above. There might be something wrong with one or more settings in your project files or the file itself might be corrupt.
BTW - The product bundle identifier should probably be following the convention of com.yourdomain.YourProductName.
You should not use bridge header. Just use import AWSDK in the swift file where you use it.
Having a problem when building with xcodebuild. My project/app builds fine with the Xcode - gui. It simply isn't finding/building the libcryptopp library which is part of the build process.
The error is:
clang: error: no such file or directory: '/Users/builder/repo/ioskpay/xcode-cryptopp/cryptopp/build/Release-iphoneos/libcryptopp.a'
This particular file should be derived from another project inside the main app - xcodebuild simply isn't correctly pointing at the right file folder which should be:
~/Library/Developer/Xcode/DerivedData
Any ideas?
To fix this, go to your project settings, go to Targets and select your main project target. Then go to Build phases. Under Target dependencies add the static library project.
This way, when you compile the main project, the static library subproject gets compiled before the main project and your static library will be available.
I had the same problem, but for a resource file .m
I opened target -> build phases -> Compile sources
and I found the file the compiler was tell it can't find duplicated: one with strange icon and the other with a normal icon. I simply removed the one with strange icon and it worked. ( I added the file multiple times and I had a merge conflict before that which made something wrong in the project file)
For your case I think you need to remove the lib from target dependencies list and add it again. This may work for you.
In Xcode Version 9.2 (9C40b) this happened when I drug a bunch of files into the project, some of which were duplicate. Rather than simply not adding the duplicates, it added them again and only the name, not the path.
In Target > Build Phases > Compile Sources each of the duplicates showed with no "...in" after them. Each one caused the clang error.
After removing all of the duplicates that Xcode collected, the project compiled and ran.
It makes you use the Project Navigator instead of managing your source files in the Finder. Then the Project Navigator can't replace duplicates like any decent file management system (ahem Finder). 🤨
My xCode info is:
I faced similar errors during xcode building projects (native swift, flutter, react native, native script) in which I got error messages related to clang compilar. Errors like:
clang-4.0: error: no such file or directory: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
clang-4.0: error: cannot specify -o when generating multiple output files
others
Despite of errors related with DerivedData for native apps can be fixed by deleting the directory and, eventually, restart xCode and even restart the machine... in this case, you will see that after deleting the directory and start building process again, the error comes back.
Then, is the moment of checking the clang installation by running clang --version. The normal output will be something like:
as you can see the InstalledDir is incorrect for xCode. In my case, some days ago I needed to install Anaconda app (R, Python, etc) and, now, I remember that I had to install some dependencies and one of them was clang and its installation was altered.
To fix this problem (in my case that I will not need anaconda any more): (edited)
1.- Delete anaconda and all its dependencies (I recommend to use App Cleaner).
2.- Re-install xCode
After reinstalling xCode, if you type again clang --version, you'll get this:
More info at: https://github.com/flutter/flutter/issues/32457#issuecomment-496161092
Hopefully, this info helps some else.
Best
Ok so by simply adding the correct -target -configuration and -scheme parameters I got this to run correctly. However due to my running this in Jenkins for autobuild purposes it still doesn't work as I'd like - getting stuck in exactly the same place. It's odd because I have the exact same code being built in another job that isn't having this problem. There is no rhyme or reason for it at this point. I will keep shooting rubber bands at it and update when I have an answer...
Sometimes Xcode performs weird.
You have to find that static library project e.g.. "filename.a" under 'Link Binary With Libraries' in Build Phase and then remove it and add it again.
I had the same problem while I was archiving my target. I removed the library and the build succeeded.
For me it was because I had removed a package or pod. I ran pod install and it fixed it
Look for the missing file in the Xcode project i.e the files may be deleted or miss placed.
add the missing files to the xcode, then everything will work fine.
Run this command :
$ conda deactivate
Lastnight I updated my iPhone to iOS 6.1, my current version of xcode wouldn't build to the phone as I needed the newest version.
I went from xcode 4.5.2 to xcode 4.6, I made 0 changes in my project file.
What used to compile completely fine, now gives me a file not found error
#import <libxml/tree.h> 'libxml/tree.h' file not found
I have my search paths correctly linked up with
$(SDKROOT)/usr/include/libxml2
and libxml2 is linked and required in build phases.
Edit:
Peculiar I changed my search paths to the following and voila..
/usr/include/libxml2
Not sure why this has fixed this issue, could anyone enlighten me as to what's changed in xcode?
In your build settings, add the following to your Header Search Paths:
$SDKROOT/usr/include/libxml2
For me what worked was adding this to header search path:
$(SDKROOT)/usr/include/libxml2
Slightly difference from other answer, probably to do with newer version of Xcode.
add: $SDKROOT/usr/include/libxml2
In Xcode6 and latest versions add this to your Header Search Paths:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2
and remember to add the search path also to the test target.
I upgraded libxml2 on my mac and then:
If you need to have libxml2 first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.zshrc
For compilers to find libxml2 you may need to set:
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
For pkg-config to find libxml2 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"