Using Emacs for iOS Development
Written by TJ Maynes

This post is primarily for iOS developers who are already familiar with Emacs and Xcode, yet want to code their objective-c applications in a distraction-free environment via Emacs.

In this post, I will be going over how to use Emacs as your primary editor for iOS Development. For reference, here is a link to my .emacs file.

Before we begin, I am going to assume you already have the installed following:

  1. Xcode (latest stable)
  2. Emacs v24.3

Inside Xcode

First, you will need to build your project in Xcode. Open Xcode and create a new Xcode project. Next, choose template: iOS > Application > Empty Application. Finally, name the product my_app.

Inside Emacs

Next, add the following to your .emacs file:

;; Objective-C
(add-to-list 'auto-mode-alist '("\\.mm\\'" . objc-mode))
(add-to-list 'magic-mode-alist
	     `(,(lambda ()
		  (and (string= (file-name-extension buffer-file-name) "h")
		       (re-search-forward "@\\<interface\\>"
					  magic-mode-regexp-match-limit t)))
	       . objc-mode))
(require 'find-file) ;; for the "cc-other-file-alist" variable
(nconc (cadr (assoc "\\.h\\'" cc-other-file-alist)) '(".m" ".mm"))

(defadvice ff-get-file-name (around ff-get-file-name-framework
				     &optional suffix-list))
  "Search for Mac framework headers as well as POSIX headers."
   (if (string-match "\\(.*?\\)/\\(.*\\)" fname-stub)
       (let* ((framework (match-string 1 fname-stub))
	      (header (match-string 2 fname-stub))
	      (fname-stub (concat framework ".framework/Headers/" header)))
(ad-enable-advice 'ff-get-file-name 'around 'ff-get-file-name-framework)
(ad-activate 'ff-get-file-name)

(setq cc-search-directories '("." "../include" "/usr/include" "/usr/local/include/*"
			      "/System/Library/Frameworks" "/Library/Frameworks"))

Next, type “M-x load-file ~/.emacs” and press enter. Alternatively, exit Emacs and log back in.

That concludes this post, if you are interested in utilizing some of Apple’s commandline tools to build out your project using Eshell or terminal check out the sources below. Also, feel free to send me an email or comment below if I have made any mistakes in this post! Thanks for reading!


[01 July 2014]
Update May 2014
Written by TJ Maynes

Its been quite a long time since I’ve updated my blog with a new post. So here it goes, I’ve been extremely focused on school and family as of this last year. I have about one more year left of school and am looking forward to graduating with a Bachelors of Science in Computer Science from the University of South Florida. I’ve been programming practically every day, where I’ve gained a lot of interest in learning mobile development. My current developer setup: Emacs, iTerm (w/zsh), and Firefox. I also enjoy listening to music on Soundcloud.

Things I’m learning/doing over the next few months:

  • Python (web development, basic scripting, and more).
  • iOS development (have an app in the app store by the end of Summer).
  • Spend more time exercising.
  • Ace my Summer classes!
[23 May 2014]
Setting Up F# In Emacs
Written by TJ Maynes

This is a quick guide to setting up F# in Emacs on OSX! The goal of this guide is to make setting up F# in Emacs on OSX an easy experience.

Before we begin, I am assuming you have the following already installed:

  1. Homebrew
  2. Emacs v24.3


  • brew install mono
  • brew install fsharp

Inside Emacs

Add the following lines to your .emacs file:

(add-to-list 'load-path "~/.emacs.d/fsharp-mode/")
(autoload 'fsharp-mode "fsharp-mode"     "Major mode for editing F# code." t)
(add-to-list 'auto-mode-alist '("\\.fs[iylx]?$" . fsharp-mode))
(setq inferior-fsharp-program "/usr/local/bin/fsharpi --readline-")
(setq fsharp-compiler "/usr/local/bin/fsharpc")

Restart emacs and use the following commmands:

  • C-C C-S, for REPL interactive program.
  • C-C C-C, fsharpc filename.fs, to compile a F#(.fs) file to an executable.

Inside eshell

  • Type command, fsharpi, and enter for REPL interactive program.
  • Type command, fsharpc filename.fs, and enter to compile a F#(.fs) file to an executable.
  • Type command, mono filename.exe, and enter to execute F# program.

Lets test our setup!

  1. Open Emacs and create a new fsharp file called Program.
  2. Copy this sample code:
  3. // Code found at
    // file: Program.fs
    let number = 5
    let rec factorial n =
        if n = 0
        then 1
        else n * factorial (n - 1)
    System.Console.WriteLine(factorial number)
  4. Save the file with C-X C-S.
  5. Compile the file with C-C C-C.
  6. Go into eshell (M-x eshell).
  7. Type 'mono Program.exe' and press enter.
  8. Done!

If you get lost, here is a link to my emacs config file. Also, checkout the F# Documentation for setting up F# on OSX!

[31 March 2014]