本文介绍了如何为Xcode项目指定其他clang选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用
,我想在我的Xcode iOS项目上自动运行它。



我需要对 clang

运行以下附加命令

  -Xclang -load \ 
-Xclang〜/ static_analysis / llvm / Debug + Asserts / lib / libPluginExample.so \
-Xclang -plugin - Xclang -example-plugin \

我想保存Xcode生成的所有其他命令,因为它很难为每个Xcode项目创建和传递这些命令。这就是为什么我选择使用 clang 插件,而不是 clang 工具的原因。



我如何做到这一点?



或者我如何提取由xcode生成的编译器标志aoutomtically,使用它们在cl工具? (becouse,正确使用工具,我需要指定所有包含目录,所有来源和所有框架)



更新: >

我在Project中添加了以下命令


,但在编译时出现错误(插件是标准示例libPrintFunctionNames.dylib clang sources):

我试图使用 libPrintFunctionNames.a ,而不是 libPrintFunctionNames .dylib ,但它不帮助。



也许原因是我在分离的源文件llvm和clang上构建我的插件,在xcode我使用其他版本的ang。

解决方案

我将在构建选项OTHER_CFLAGS中指定其他Clang选项。您可以在

  target / project Build Settings  - > Apple LLVM 5.0  - 自定义编译器标志 - >其他C旗帜

也可以为 xcodebuild ,例如

  xcodebuild -scheme SampleProject build OTHER_CFLAGS = -  Xclang -load -Xclang / path / to / libPrintFunctionNames .dylib -Xclang -plugin -Xclang print-fns

xcodebuild 是很方便的,当你不想保持只有OTHER_CFLAGS不同的2个目标。



但你是对的,看起来你真的需要链接到与铛本身链接的相同的库。至少我从,构建了带有下载的库的插件,它与的clang一起使用,但doesn从Xcode的clang工作 - 我遇到以下错误:

 错误:无法找到插件'print-fns'

我创建了Xcode工作区,它构建了Clang插件,并展示了如何尝试使用默认iOS应用。您可以在

找到它

I have created my custom clang plugin with help of this tutorialand 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

,but in compile time there is error (plugin is standard example libPrintFunctionNames.dylib from clang sources):

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.

解决方案

I would specify additional Clang options in build option OTHER_CFLAGS. You can do so in

target/project Build Settings -> Apple LLVM 5.0 - Custom Compiler Flags -> Other C Flags

Or you can specify OTHER_CFLAGS for xcodebuild, for example,

xcodebuild -scheme SampleProject build OTHER_CFLAGS="-Xclang -load -Xclang /path/to/libPrintFunctionNames.dylib -Xclang -plugin -Xclang print-fns"

xcodebuild is convenient when you don't want to maintain 2 targets which differ only in OTHER_CFLAGS.

But you're right, it looks like you really need to link against the same libraries as clang itself is linked. At least I've downloaded Clang+LLVM 3.3 binaries from http://llvm.org/releases/download.html , built the plugin with downloaded libraries and it works with clang from http://llvm.org, but doesn't work with clang from Xcode - I encounter the following error:

error: unable to find plugin 'print-fns'

I've created Xcode workspace which builds Clang plugin and shows how you can try to use it with default iOS application. You can find it at https://github.com/vsapsai/ClangPluginExample

这篇关于如何为Xcode项目指定其他clang选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 06:06