I am trying to use clang-query to run matches against obj-c files that import Foundation but its not working, After building clang-query by moving it to the tools/extra folder, I run it using this command:
./clang-query MyClass.m -- -extra-arg-before "-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk"
But I'm getting this error:
fatal error: 'stdarg.h' file not found
#include <stdarg.h>
How should I be running clang-query to analyse my objective-c sources?
After doing more research I found out that the right approach is to use
libToolingbased tools. As stated in their documentation:For Xcode projects, this file can be generated like this:
xcodebuild -project PROJECT_NAME.xcodeproj | xcpretty -r json-compilation-database --output compile_commands.jsonyou will need to install the
xcprettygem. (gem install xcpretty)Source: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
UPDATE: IF like me, you are having issues with the
compile_commands.jsonfile generated from xcodebuild logs, just pass this commands to your binary:You might need to update some of the parameters based on your system configuration but this is working fine for me currently.