Skip to content
Emacs auto-complete clang backend for Objective C devlepment for iOS
Emacs Lisp
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


The AC sources for Clang and Objective-C development. Combine the power of AC, Clang and Yasnippet.

If you don’t have Yasnippet, I recommend you install one. If you don’t want to install Yasnippet, you can try snippet.el instead. If you don’t install any of them, this script will still work for you any way.

This elisp has been simplified and adapted to support well pure Objective-C development (no C++).


Here is my configurations for AC and auto-complete-clang for your reference.

(add-to-list 'load-path (concat myoptdir "AC"))
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories (concat myoptdir "AC/ac-dict"))

(require 'auto-complete-clang)

(setq ac-auto-start nil)
(setq ac-quick-help-delay 0.5)
;; (ac-set-trigger-key "TAB")
;; (define-key ac-mode-map  [(control tab)] 'auto-complete)
(define-key ac-mode-map  [(control tab)] 'auto-complete)
(defun my-ac-config ()
  (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
  (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
  ;; (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
  (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
  (add-hook 'css-mode-hook 'ac-css-mode-setup)
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)
  (global-auto-complete-mode t))
(defun my-ac-cc-mode-setup ()
  (setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))
(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
;; ac-source-gtags


  • Now clang is able to parse codes from standard output. Saving the file before parsing is no longer necessary. So the default value of ac-clang-auto-save is now changed to nil. If you still use the old version of clang and this may not work for you. In this case, you can change the ac-clang-auto-save back to t.


  • clang fails to find the standard inlcude files?

    It is because clang’s include file search path is not correct. Here is the solution:

    • find out the include file search pathes of your g++:
      echo "" | g++ -v -x c++ -E -

      you wil get something like this:

      #include "..." search starts here:
      #include <...> search starts here:
      End of search list.
    • setting the ac-clang-flags to include these default include pathes. e.g.,
      (setq ac-clang-flags
            (mapcar (lambda (item)(concat "-I" item))

    You can put it into your .emacs file.

    Then code completion works just fine!

You can’t perform that action at this time.