I have created my custom clang plugin with help of this tutorial
and I want to run it automatically on my Xcode iOS project.
I need to run following additional commands on clang,
-Xclang -load \
-Xclang ~/static_analysis/llvm/Debug+Asserts/lib/libPluginExample.so \
-Xclang -plugin -Xclang -example-plugin \
I would like to save all other commands generated by Xcode, because it is difficult to create and pass those commands for every Xcode project. That is the reason why I choose to use clang plugin but not clang tool.
How can I do achieve this?
Or how can I extract compiler flags generated by xcode aoutomtically, to use them in clang tool? (becouse, for correct using tool I need to specify all include directories, and all sources, and all frameworks)
Update:
I have added thous commands in Project
Settings -> Build Phases -> Compile Sources (double click on source)
, but in compile time there is error (plugin is standard example libPrintFunctionNames.dylib from clang sources):
error: unable to load plugin '/Users/...llvm/Debug+Asserts/lib/libPrintFunctionNames.dylib': 'dlopen(/Users/.../llvm/Debug+Asserts/lib/libPrintFunctionNames.dylib, 9): Symbol not found: __ZN5clang11ASTConsumer21HandleInterestingDeclENS_12DeclGroupRefE Referenced from: /Users/.../llvm/Debug+Asserts/lib/libPrintFunctionNames.dylib Expected in: flat namespace in /Users/.../llvm/Debug+Asserts/lib/libPrintFunctionNames.dylib' Command /Applications/Xcode 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
I have tried to use libPrintFunctionNames.a instead of libPrintFunctionNames.dylib, but it doe not help.
Maybe the cause is that I built my plugin on separated source files of llvm and clang, and in xcode I use other version of clang. I will check that.