User Tools

Site Tools


how_to_use_xcode2_as_ide_on_a_mac

This is an old revision of the document!


How to use Xcode2 as IDE on a Mac

While you probably need a PC to burn the MBHP-Loader into the PIC, you can stick to your beloved Macintosh while coding your C-Applications!

And more than that: you are able to use Apple's powerful Xcode IDE and don't leave that except for sending the .syx file! You can even debug your MIOS C-Applications with the MIOS C Simulator - Debugger - although this is in a very early development state, please contribute code! audiocommander.

First, go and install GPUUTILS and SDCC on your mac if not already done!

If you have already SDCC running and calling “sdcc -v” in terminal gives you the info you're running 2.5. or higher, you have the most complicated step already completed!


Now, let's go on to real cool stuff and switch to Xcode.

I presume, you have downloaded the MIOS-C-Skeleton, unpacked it in an appropriate folder and you're ready to start coding your own nifty MIOS-App.


Creating a new project

Create a new, empty project from the File-Menu. Select your MIOS-application folder.

Now drag your files into the project. This should be mainly main.h and main.c, but it won't hurt if you add all the files in your directory.

Edit the file “MAKEFILE.SPEC” to your needs. That means, if you have additional classes, you should add them to “MK_ADD_OBJ myfile.c”


Setting up the make target

Because things change a lot, we're making it easy: we set up a “makefile”-target, so with a press of button, your new makefile is generated!

Note, that you can skip this step if your makefile will never change. Neverthess, the procedure is the same as setting up your main target, so you should read it anyway :)

  • go to “Project > New Target” and choose “Shell Script Target”. Name the target “Makefile”
  • open the Target-Tree, open the target “Makefile” and double-click on “Run Script”
  • you'll find now:
# shell script goes here
exit 0

type this:

# shell script goes here
 
PATH=/usr/local/bin:$PATH
 
cd $SRCROOT/tools
./mkmk.pl $SRCROOT/MAKEFILE.SPEC
 
echo Makefile replaced.
echo Success.
 
exit 0

Don't forget to close the panel or switch forth and back to the next window item (“Comments”), because sometimes the changes are not recognized.

You're done!

Once you select “makefile” as your primary target and press “build”, the pearl tool ./mkmk.pl is invoked, generates your Makefile, deletes the unnecessary “makefile.bat” and moves the new makefile in your directory root.

If you want to, you can now add “$(SRCROOT)/MAKEFILE.SPEC” to the “Input Files” and “$(SRCROOT)/Makefile” to the “Output Files”. Then Xcode2 checks if any of the input files is newer than the output files and will start the build only if necessary.


Setting up the primary application target

Now this is basically the same as before. Repeat the steps above, but call your target like your application. The bash script would look like this in the “Run Script”:

# shell script goes here
 
PATH=/usr/local/bin:$PATH
 
cd $SRCROOT
make
 
exit 0

As you see, the only trick is, to invoke the makefile.

Don't forget to choose your new current target, your application. Otherwise only your makefile is generated again :)

Easy, isn't it?


Debugging with Xcode

go to the ACSim page and grab the debug sources. Note, that these are far from being complete. If you add functions in your own project, please update the files here in the wiki!

Add the debug-files to your Xcode project, and adapt what needs to be adapted (defines, includes etc…).

Now add a new target, choose “Carbon Shell Tool” and name it “MIOS_Debug” or whatever you like.

Now you have to add the Carbon Framework (Right Mouse on the Folder “Libraries”, Add Framework, Search for Carbon).

At this point you just have to make sure, that “ACSim_console.c”, “ACSim_mios.c” and “ACSim_toolbox.c” are the only files that is included for this target. If you open the debug target, you see “Compile Sources (3)”. If there are more files than “debug.c”, delete them from this target.

Important: If you debug your C-Application, you need to make inputs from the command-line, which can't be done from the debugger-console. Launch the “Standard I/O” Window from the “Debug” Menu. This console-window is only available in debug-mode!

If you have questions, feel free to post them here: http://www.midibox.org/forum/index.php?topic=6527.0

how_to_use_xcode2_as_ide_on_a_mac.1189289881.txt.gz · Last modified: 2007/09/10 23:05 (external edit)