Archive for September, 2019

How I got Rust working in Xcode

A while ago, I posted about how I set up Xcode to work with Python. Yesterday, I was taking a class on Rust and decided to use my friendly neighborhood (sp)IDE(rman) coding environment, namely Xcode.

I’m not going to say it was a stunning success but there was enough interest that I thought I’d share the steps so you too could embrace Rust through Xcode.

Install Rust. You start, as one does, by installing Rust. Hop over to to grab a copy of the tools. They install to ~/.cargo, for whatever reason. I put a link in to / usr/local/bin.

Create a Project. Create an external build system Xcode project by choosing File > New > Project > Cross-platform > External Build System > Next. Enter a product name (I called mine “Rust” because that’s exactly how creative I am.) and set your build tool (in my case, /usr/local/bin/rustc because of the link). Save it somewhere convenient.

Create a source file. Apparently “rs” (rust source?) is the proper extension. I went with “test” as my name. File > New > Empty >

fn main() {
    println!("hello world");

Don’t forget to add some code.

Compile. Edit your scheme.  Choose Run > Info > Build Executable > Other and select your compiler. Adding it to /usr/local/bin made it easier to select rustc for me. Then uncheck Debug executable because you’re not debugging the Rust compiler.

At this point you can click Run and you’ll see the standard option message because you haven’t specified what it should run.

Back in the scheme editor select Run > Arguments and add the source file and output file. Unfortunately, I could not get this to work with SRCROOT at all, so here it is in all its glory with complete paths.

The Pre-action removes any build product from a previous run:

So here we are. With luck, it compiles. If not, the errors appear in pretty horrible form in the Xcode console, where curses is what we do, not how the console interprets pretty text output.

You can get slightly less horrible feedback by adding the launch argument: –error-format=json

Yeah, it’s wordy but it’s slightly less awful.

Pick a path. Unlike python, rust is just a compiler. If you build, and then add a step execute, the execution output (unlike compiler errors) will not normally print at the Xcode console. The challenge is to get that information in some form where you can access it.

At first I went with a little post-action osascript and threw up the output in a separate window:

But I really wanted to make it work with the console So back I went to Applescripting. Instead of rustc, I changed my build tool to osascript:

I added this instead to my run scheme arguments.

Yep, I’m using osascript to run a shell script that just compiles with rust and then runs it, passing the output through back to Xcode.

I know this is bad. I know I should be ashamed. I hang my head.

But you know what? It works. Stray osascript-crud and all:

I’m not sure how much this makes me a programming outcast but it was kind of fun to figure out how far I could push my beloved enemy Xcode.

Repost: September 11, 2006

I originally wrote this on September 11, 2006, 5 years after the WTC. I’m reposting this on September 11, 2019, 18 years after.

During high school, I spent nearly every waking hour in the company of the Klitzman twins. We took biology together, English, physics, chemistry, social studies, lunch and band. I’d walk from class to class to class and they’d always be there. After school, we’d carpool together to after-school activities. I believe I spent more time with the twins than their parents did.

We had little in common. I was a computer geek, into science fiction and programming. They were athletic. They played tennis and were well liked. The band-twin was excellent at her instrument. I just played along and tried not to hit too many sour notes. Socially, we lived in very separate worlds and I never got to know them. We co-existed rather than interacted. I am the poorer for that.

They both became adults of great accomplishment. They went, I believe, to Princeton. From what I have googled, Karen did graduate work at Columbia and became the vice president of research for the New York Mercantile Exchange. Donna attended medical school and now practices medicine in New Jersey. It sounds like they were amazing people.

Five years ago today, a plane flew into the office of Cantor Fitzgerald and vaporized Karen. From what I can tell, her body was never found. Along with her at the World Trade Center died Edward Fergus and Thomas Collins and Christopher Panatier, who attended High School East at the same time we were at West and Martin Lizzul who graduated West a few years after we did. I don’t think I ever met or knew them, but they were from home.

The minutes of the board of the Half Hollow Hills school districts lists parents, uncles, aunts, cousins, and friends. A couple of teachers at West Hollow lost nearly a dozen friends all at once. Friends and acquaintances spent months going to memorial service after memorial service.

Today, all the cable channels will be replaying memories of that time. And tomorrow, Apple is going to introduce some new iPods and iMacs and life will go back to normal.

Life is short and unpredictable. We all have many missed opportunities and people of value that we never got to really know. Rather than focus on the obsessive hatred and corrosive philosophy that motivated the events of 9/11/2001, today I’m going to take a moment to appreciate and better get to know the people in my life.

We are surrounded by good people. Sometimes we forget about that.