xcodebuild failure clang:error no such file or directory:
Solution 1
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.
Solution 2
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.
Solution 3
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
Solution 4
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). 🤨
Related videos on Youtube
Todd McGuinness
Updated on August 06, 2020Comments
-
Todd McGuinness over 3 years
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?
-
iDev about 11 yearsYou are using Xcode version 4.6, right?
-
David Ansermot almost 8 yearsStill the problem ?
-
Pedro Martín almost 5 yearsHi, maybe this can helps you: github.com/flutter/flutter/issues/32457#issuecomment-496161092
-
-
Shane Gannon about 10 yearsHi Todd - how did this turn out?
-
Alexander over 6 yearsThat helped me either.
-
Pedro Martín almost 5 yearsIn some cases in which you face this issue related to any cross-platform framework (flutter, nativescript, reactnative) you will not able to change the xCode settings directly in IDE. In this case, maybe you have a problem with clang installation similar to me -> github.com/flutter/flutter/issues/32457#issuecomment-496161092. This fix will helps you to prevent not only the mentioned issue, in addition, all issues related to clang compiler.