所以最近我一直在尝试建立一个基于Vim的iOS工作流程。
我找到了 clang_complete,并在 .vimrc 中设置了 clang 用户选项
let g:clang_user_options='-fblocks -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300'
,如下所述: http://www.zenskg.net/wordpress/?p=199#comment-229
并添加了一些framework/header/lib路径。我不会发布整行内容,因为它太大了。
因此,我在命令行中使用 clang
(使用相同的选项)测试了项目中一个文件的编译,它编译得很好,但仅如果我使用-arch armv6/7
标志。如果我不这样做,它会尝试编译 i386 并抱怨缺少头文件。
到目前为止,一切都很好。现在我只需使用我为 clang
提供的完全相同的选项,以及 .vimrc
中 clang_complete
的用户选项,对吗?
没有。当我这样做并尝试在 Vim 中自动完成一个单词时,它会
unknown argument: '-arch'
在 Vim 的 QuickFix 列表中显示。我有点需要这个标志 - 我应该如何进行?
任何有用的想法。我很想让 iOS 代码完成在 Vim 下工作。
So recently I have been trying to set up a Vim-based iOS workflow.
I found clang_complete, and have set the clang user options in my .vimrc like so
let g:clang_user_options='-fblocks -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300'
as described here: http://www.zenskg.net/wordpress/?p=199#comment-229
and added a few framework/header/lib paths. I'm not going to post the whole line because it is huge.
So I tested the compilation of one of the files in my project using clang
from the command line (using the same options), and it compiles fine, but only if I use the -arch armv6/7
flag. If I don't it tries to compile for i386 and complains of missing header files.
So far so good. Now I just use the exact same options I gave to clang
, to clang_complete
's user options in my .vimrc
right?
Nope. When I do that and try to autocomplete a word in Vim, it says
unknown argument: '-arch'
in the QuickFix list of Vim. I kinda need this flag- how should I proceed?
Any ideas useful. I would love to get iOS code completion working under Vim.
发布评论
评论(3)
clang_complete 运行
clang -cc1
,这会导致编译器前端运行而不是驱动程序。编译器前端不理解-arch
选项。clang -cc1 --help
将向您显示可能的选项。您可能应该指定-triple
或-target-*
之一。如果您不确定要使用什么,可以像以前一样手动运行 clang,但以详细模式 (
-v
) 运行。这样它将打印clang -cc1
命令行,您可以在其中找到适当的参数。clang_complete runs
clang -cc1
, which causes the compiler front-end to run and not the driver. The compiler front-end doesn't understand the-arch
option.clang -cc1 --help
will show you the possible options. You should probably specify-triple
or one of-target-*
.If you're not sure what to use, you can run clang manually as you did, but in verbose mode (
-v
). This way it will print theclang -cc1
command line, where you can find the appropriate arguments.默认情况下,clang_complete 使用 clang 二进制文件
/usr/bin/clang
,但 Xcode 不是。它使用 clang 库/Developer/usr/clang-ide/lib/libclang.dylib
。它们并不完全相同。如果您要复制 XCode 正在使用的选项,则必须确保 clang_complete 也使用库版本。.vimrc 文件中类似的内容应该可以做到这一点:
当我这样做时,
-arch i386
被接受。(PS - 我在让 clang_complete 进行 iOS 开发时遇到了一些其他问题。您可能想看看这个分支:https://github.com/krisajenkins/clang_complete。我对 clang 太陌生,无法真正知道我在做什么,但它对我有用......)
By default, clang_complete is using the clang binary
/usr/bin/clang
, but Xcode isn't. It's using the clang library/Developer/usr/clang-ide/lib/libclang.dylib
. They're not quite the same. If you're copying the options that XCode is using, you'll have to make sure clang_complete uses the library version too.Something like this in your .vimrc file should do it:
When I do that,
-arch i386
is accepted.(PS - I had a couple of other problems getting clang_complete to work for iOS development. You might want to check out this fork: https://github.com/krisajenkins/clang_complete. I'm too new to clang to really know what I'm doing, but it's working for me...)
使用 5.1 sdk,即使使用 libclang.dylib,我也无法接受 -arch。
经过一番摸索(即,按照建议使用
-v
标志手动运行 xcodebuild 生成的 clang 命令),我最好的设置是:添加
-cc1
是我唯一做的事情在 Stackoverflow 或其他地方的其他资源中没有看到提到(显然这个标志允许 clang 驱动程序和原始 cc1 标志的混蛋组合通过)。一旦添加了它,它突然就至少可以用于 Cocoa 和 UIKit 完成(尝试输入[NSString Cx Cu
)。然而,有些东西仍然被轻微破坏。
键入
:copen
完成后(成功或其他)我会看到以下内容:此外,即使我已将各种
-I
标志添加到我的.clang_complete< /code> 文件或直接到
clang_user_option
s 字符串,clang_complete
仅适用于我的项目中的部分标头,但不是全部标头...没有明显的原因为什么可以工作但其他人则不然。 (欢迎提出建议)。Using the 5.1 sdk I wasn't able to get -arch accepted even when using libclang.dylib.
After some futzing (namely, manually running the clang commands produced by xcodebuild with the
-v
flag as suggested), my best setup was:adding
-cc1
is the only thing I don't see mentioned in other resources on Stackoverflow or elsewhere (apparently this flag allows the bastardized combination of clang driver and raw cc1 flags to go through). Once this was added it suddenly just worked at least for Cocoa and UIKit completion (try typing[NSString C-x C-u
).However, something's still mildly busted.
Typing
:copen
I see this after a completion (successful or otherwise):Also, even though I've added various
-I
flags to either my.clang_complete
file or directly to theclang_user_option
s string,clang_complete
only works with some but not all of the headers in my project... with no apparent reason why one works but not others. (Suggestions welcome).