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.
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 the clang -cc1
command line, where you can find the appropriate arguments.
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:
filetype on
autocmd FileType objc let g:clang_use_library=1
autocmd FileType objc let g:clang_library_path='/Developer/usr/clang-ide/lib'
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...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With