Using Emacs for iOS Development

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.

Xcode Screencast GIF

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
				    (search-dirs
				     fname-stub
				     &optional suffix-list))
  "Search for Mac framework headers as well as POSIX headers."
  (or
   (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-do-it))
   ad-do-it))
(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!

Sources:


Update May 2014

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!

VHS Covers

In my youth, going to Blockbuster was like being a kid in a candy store. This was non-“instant” time period. The only way you knew if a movie was available or not was by how many VHS tapes were on the walls or aisles (like a grocery store for entertainment). Oh and if you really wanted to get a movie you would go to the front counter and see if someone had just returned it. I’m very keen on certain smells and Blockbuster had the smell of an aged public library (even back in the 90’s). I may seem a bit old fashioned but I remember what the experience of being among the lucky few to see a newly released movie first was like. I remember knowing exactly where the new releases were, the average time of being in there (with my parents it wasn’t very long and with my aunt, to my luck, it would be awhile), and where each section would take me. Among all this talk about Blockbuster, what I truly want to remember is the VHS box covers that paralleled an art gallery.

The science fiction section had newer movies on the top shelf like alien:resurrection, dark city and pitch black. The bottom shelves had older movies like Kubrick’s 2001, Ridley Scott’s Alien, James Cameron’s Aliens, John Carpenter’s The Thing, A Clockwork Orange, Blade Runner, Robert Zemeckis’s Back to the Future, and many others. A couple of notable box covers include the minimalist 2001: A Space Odyssey with Keir Dullea in a space helmet, The Thing had piercing prism light coming from the face of some-“thing” in a parka, and Alien had green-goo emitting out of the cracks of a rather large egg. There are many reasons why these covers were just so damn good, but the fact that they didn’t reveal too much only made me want to see them more. There was so much mystery to green egg and made you question what the hell was going on in The Thing? I remember the fonts also playing a part on the anticipation I would have for a movie (the more creative, the better). Also, I don’t believe that I mentioned this but I did spend a lot of time reading the synopsis, or “definition”, of the movie on the back cover. This would reveal a little more for me, so the anticipation would elevate.

I knew that at this particular childhood store, the horror section was facing opposite of the science fiction section. I always faced my back against this section; early on my aunt traumatized me with a Chucky doll (from Child’s Play) that she got from Spencer’s Gifts. Looking back on it, I would actually get the “sweats” from walking down the aisle and I didn’t even look at a single box. Eventually I gained the courage to look down this mysterious and possibly dangerous “other side”, while wearing my light-up shoes (still skipping the sight of the Chucky movies though). I remember seeing The Funhouse, Hellraiser, Army of Darkness, Jack Frost (not the one with Michael Keaton but still in the same category of shit), Halloween, Scream (which was huge in the late nineties), and Jaws. Jaws was interesting because the shark was made to look huge and vicious as well as being very capable of swallowing a beautiful woman whole. Jack Frost was one the first covers that I saw with a hologram on it, where a happy snowman turned into an evil one. The Funhouse featured a clown, a lot like Pennywise from IT, with blood wrapped around it’s lips and a circus-esque theme to it. I wasn’t afraid of clowns, but this one happened to be very different, more raw, which makes sense because it was directed by Tobe Hooper.

For that matter, a lot of sounds in this particular time felt synthesized. I believe that I may have been too young to see these movies, but I knew that one day these would probably be my favorite.

I only hope to one day pay homage to these experiences because one day kids aren’t going know what a movie store was. Check out Beyond the Black Rainbow and VHS (all on Netflix), if you’re interested in seeing a director’s take on that same love for VHS art galleries. If you too remember looking at VHS box covers like an art gallery, please comment below and thank you for reading.