NXC on Xcode?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
fuzzball27
Posts: 103
Joined: 29 Sep 2010, 17:14
Location: US

NXC on Xcode?

Post by fuzzball27 »

I'm interested in what Xcode is and how it can be used to write NXC programs.
Skittler wrote about it in the Mac vs. PC discussion here: https://sourceforge.net/apps/phpbb/mind ... ?f=3&t=234
How does Xcode work? How do I use it for NXC? I'm excited to have an available IDE for NXC/Mac programming :geek:
fuzzball27 >>-->
rghansen
Posts: 67
Joined: 12 Oct 2010, 17:44

Re: NXC on Xcode?

Post by rghansen »

I've written quite a bit of NXC with Xcode. But I just use it as a fancy text editor and I'm easy to please.


Any body know how to get a bit more out of Xcode?
fuzzball27
Posts: 103
Joined: 29 Sep 2010, 17:14
Location: US

Re: NXC on Xcode?

Post by fuzzball27 »

I've noticed that you must be an apple developer to have Xcode...unless you download it from a third party site such as mac.softpedia.com. Is that legal? I don't do illegal downloads.
fuzzball27 >>-->
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: NXC on Xcode?

Post by tcwan »

fuzzball27 wrote:I've noticed that you must be an apple developer to have Xcode...unless you download it from a third party site such as mac.softpedia.com. Is that legal? I don't do illegal downloads.

Apple Developer registration is free unless you want to distribute apps via the iTunes store (currently for iOS, will be available for Mac Apps).
There is no restriction on the use of XCode development tools for Mac. If you have a Mac, a version of XCode already comes in your OS X Installer disk.

By registering online in ADC, you can access the latest publicly available version of XCode for free. Paying Developers get to access beta versions of XCode and pre-release Mac OS X (depending on tier), etc.
markcrosbie
Posts: 34
Joined: 30 Sep 2010, 09:56
Location: Ireland
Contact:

Re: NXC on Xcode?

Post by markcrosbie »

Hi Fuzzball,

What exactly are you looking from XCode? Do you want a syntax highlighting editor? There are many good editors available that do syntax highlighting (I use Smultron, just a personal preference). Or do you want XCode to actually build the NXC programs for you? For that you'll have to edit Makefiles.

Lucky for you I wrote a tutorial on how to use Xcode to write NXC programs for the NXT on the Mac: http://mastincrosbie.com/Marks_LEGO_pro ... _10.5.html. So that should answer your question.

Enjoy!
Mark
fuzzball27
Posts: 103
Joined: 29 Sep 2010, 17:14
Location: US

Re: NXC on Xcode?

Post by fuzzball27 »

markcrosbie wrote:Hi Fuzzball,

What exactly are you looking from XCode? Do you want a syntax highlighting editor? There are many good editors available that do syntax highlighting (I use Smultron, just a personal preference). Or do you want XCode to actually build the NXC programs for you? For that you'll have to edit Makefiles.
A syntax highlighting editor would be nice. I've been using TextEdit to write programs, and I just saw this as a step up from that. The reason I'd like to use Xcode is because it is made by Apple and I can use it for more than just the NXT. I'm curious, does Xcode detect programming errors as you are writing NXC programs such as in Brixcc? What do you mean by Xcode building NXC programs?
fuzzball27 >>-->
fuzzball27
Posts: 103
Joined: 29 Sep 2010, 17:14
Location: US

Re: NXC on Xcode?

Post by fuzzball27 »

I've downloaded Xcode, but I'm a little confused. I read the tutorial, but I wasn't able to follow it because it doesn't specify what type of project to use in Xcode and it didn't explain how to direct Xcode to use the nbc compiler. How do I configure Xcode to use NXC?
fuzzball27 >>-->
markcrosbie
Posts: 34
Joined: 30 Sep 2010, 09:56
Location: Ireland
Contact:

Re: NXC on Xcode?

Post by markcrosbie »

Hi Fuzzball,

Let's take a step back here and ensure we're all on the same page. Apologies in advance if you are an experienced programmer already, as I don't mean offense.

XCode is a fully featured development environment for Mac OS. You can use it to build GUI-driven programs, command line programs or indeed anything you want. XCode can use whatever compiler toolchain you give it and is as customisable and flexible as all the major programmer IDEs available (e.g. Eclipse, NetBeans, VisualStudio). XCode is specifically targeted for Mac development; it supports Objective-C, Interface Builder and iPhone development. Using it for programming the NXT is like using a sledgehammer to hit a nail.

If all you want is a syntax-highlighting editor then just download Smultron, set the Syntax Definition menu to "C" and off you go; lots of pretty syntax highlighting colours. XCode does not understand the NXC function libraries, so you won't be able to take advantage of features such as prompting for function arguments or auto-completion of function names that you would expect in a professional IDE. The NXC compiler is also not native to the Mac, so you have to configure XCode to call it as an external-toolchain. That is the point of the customised Makefile I created and which you can download off my website.

If none of this makes sense to you then I do not recommend using XCode. If you want to use it just because "it's on the Mac" then you are not selecting your tools correctly. You should select a tool that is appropriate for the job, and not because the Apple website tells you to use it.

Again, apologies if I have offended, but you need to take stock of what your skill-level is, what you want to achieve and select the shortest path between the two points.

Mark
lizard381
Posts: 44
Joined: 16 Nov 2010, 19:57

Re: NXC on Xcode?

Post by lizard381 »

fuzzball27 wrote:I've downloaded Xcode, but I'm a little confused. I read the tutorial, but I wasn't able to follow it because it doesn't specify what type of project to use in Xcode and it didn't explain how to direct Xcode to use the nbc compiler. How do I configure Xcode to use NXC?
Hi Fuzzball,

The makefile is what directs Xcode to use the nbc compiler. When I use XCode for NXC, I
  • 1. Click New Project
    2. Under Other, select External Build System
    3. Once you have a project [suppose the name is Project], you add a file called Makefile to Project and copy the contents of the Makefile from the tutorial
    4. You should also right click Project and add a "source" group and a "build" group
    5. In your source group you add your nxc files. When you add them, you can right click them and go to Get Info. Change the File Type from text to sourcecode.c or sourcecode.nqc to get syntax highlighting.
After this, the only thing left is to add your Makefile appropriately as indicated in the tutorial. One thing I noticed is that since you no longer need to use nxtcom to download the program to the nxt, just nbc, you can delete that part and edit the nbc command.

Does that make sense? I could post my own edited Makefile.

Cheers,
Kami
I haven't grown past my playing with Legos stage and I don't think I want to :)
Blog: http://nuhlikklebickle.blogspot.com
Kami
fuzzball27
Posts: 103
Joined: 29 Sep 2010, 17:14
Location: US

Re: NXC on Xcode?

Post by fuzzball27 »

Thank you! I got it working great. No offense taken Mark; I'm new to programming, but I preferred to use Xcode to get used to a universal IDE that was easily attainable (no downloads).
fuzzball27 >>-->
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests