[Developing in NXC using XCode]

Lego Mindstorms Tutorials Date: Jan 2012

There are a number of tools and IDEs you can use to create programs for the NXT Mindstorms. I would argue that the best tool should support most operating systems and involve C or a similar language (there is a limited memory on the brick so good memory management becomes an issue). While Robot-C is probably the best choice in terms of integration with the brick, it is a commercial tool and it only work on Windows so far. After comparing a number of options, I chose NXC as a pretty good alternative to Robot-C. It supports a lot of things like sensor and motor management, playing of sounds, basic 2D and 3D graphics, etc. Most importantly, you can compile your programs from the command line or from XCode. This tutorial assumes knowledge of XCode 4 and of C. The NXC programming guide is a good reference.

Setting up an XCode project

This blog by Mark C summarises the main points of NXC XCode development and provides a downloadable Hello World program. Rather than repeating what was said before, I would like to give a step-by-step guide to creating a project from scratch. The reason for that is that even if you download somebody else's HelloWorld program, XCode does not allow you to easily change the project name so it is always easier to create a new project.

1. Download

The first step is to download the latest nxc compiler and nxt firmware. Put the compiler on your disk, e.g. to the /Developer folder. Also, you might find the NeXT Tools useful.

Please read the tutorial Setting up NXC Development on a Mac if you are not sure about this step.

2. Create project

In XCode, choose 'Create new project' and select 'External Build System' under Mac OS X -> Other. This will take care of some basic build and target setup. In this example, we name our project 'MyProject'.

Creating a new XCode project step 1

Creating a new XCode project step 2



Hi Felix,

wow looks cool! Finally something specifically for NXC. And it's nice they include the latest compiler as well. Thanks a lot for sharing and have nice holidays too!

Hi Lenka!
It's me again. I more or less found a more specific IDE for mac! :D
With this bundle for Textmate you can have proper syntax highlighting and compile and download to the brick using cmd+R. It's great!
cheers and merry x-mas.
Sorry, I must have misunderstood you then. I thought you wanted to have different targets for different build settings, but with the same source. Your solution to the problem you mention is ok then.

Also thanks for the note about bluetooth - I am using USB so haven't encountered the problem yet.

Lenka, I think this is not enough. Think a Project "Tribot" where you have 2 bots, one called Tribot.nxc, the other Second.nxc. In your case PROGRAM=Tribot, and it builds Tribot.nxc. If you add a target "Second" it will not build(compile) the other source.

You can't simply add new source files for new robots in $(SOURCE) and compile them as you need them.

In order to do so, you would need to change the makefile to produce $(TARGET_NAME) executable from $(TARGET_NAME) source.

The sources location is just relative to the makefile and has afaik no problem in you change $(PROGRAM) to $(TARGET_NAME).

At least this is the regular setup I am using all the time to create different robots from different nxc sources in the same XCode Project (fired up by different XCode targets)

On the options side you are right... one should use -d. I just had issues with downloading over Bluetooth with nbc -d.... so I switched to nxtcom with worked for me perfectly.

{Please enable JavaScript in order to post comments}

NXC UserInteraction Library

The User Interaction (UIn) Library helps you create standard user interfaces (multi-line aligned texts, buttons, menus, etc.) and capture user actions on the NXT brick. The library works with the intelligent brick buttons and keeps all your sensor ports free for your program to use.

Setting up NXC Development on a Mac

This tutorial provides a step-by-step guide for setting up your Mac or Linux machine and your NXT brick for development with NXC. We will use the enhanced NXC firmware in order to enable extended functions for development.


ShooterBot spins around, looking for close targets to shoot at. Its proximity sensor starts firing signals when an object gets as close as about 20cm, at which point the robot gives a warning by showing blue instead of green light. The light turns red after about 2 seconds provided that the object does not move away and the robot shoots a ball at it.

Adaptive Robot Controller

A robot neural controller where obstacle-avoidance and random-walk neurons observe level of their irritation and randomly reconfigure their connections to motors when the irritation reaches a specified threshold is presented and tested.

Robot Flocking: Sensors and Control

This paper discusses various kinds of robot sensory input, approaches to motor control and ways they could be used for flocking. Focus is put on vision and Gibsonian optic flow that could be utilised by robots with advanced behaviour.


The main purpose of pyCreeper is to wrap tens of lines of python code, required to produce graphs that look good for a publication, into functions. It takes away your need to understand various quirks of matplotlib and gives you back ready-to-use and well-documented code.