index rss mastodon twitter github linkedin email
Álvaro Ramírez

Álvaro Ramírez

08 January 2016 Emacs Objective-C completion with Irony

Install libclang on Mac

brew install llvm --with-clang

Configure Emacs

(use-package irony :ensure t
  (add-hook 'objc-mode-hook 'irony-mode)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))

(use-package company-irony :ensure t
  (add-hook  'objc-mode-hook (lambda ()
                               (setq-local company-backends '((company-irony)))))
  (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands))

install irony server


M-x irony-install-server

NOTE: Needs libclang: Install with "brew install llvm –with-clang" By default, irony-install-server did not find libclang on Mac OS. irony-install-server invokes cmake for you. Work around by adding:


For example:

cmake -DCMAKE_PREFIX_PATH=/Users/your-user-name/homebrew/opt/llvm -DCMAKE_INSTALL_PREFIX\=/Users/your-user-name/.emacs.d/irony/ /Users/your-user-name/.emacs.d/elpa/irony-20160106.1223/server && cmake --build . --use-stderr --config Release --target install

Compilation database

Install xctool

brew install xctool

Generate compilation database

xctool -sdk iphonesimulator -arch x86_64 -scheme SomeScheme -reporter pretty -reporter json-compilation-database:compile_commands.json clean build

Set Irony's database path

M-x irony-cdb-json-add-compile-commands-path