Easily solved by the typical XCode user. I don't think you're properly visualizing the level of cluelessness of the would-be consumer of a pre-made Arduino sketch. "rename main.cpp to foo.pde in a directory name foo, and put all the other file there too" just has SO many things that could go wrong.

Quote

On the other hand what is the benefit of working with pde files in XCode?

given a sketch containing .pde, .ino, .cpp, .c, and .S files, the .cpp, .c, and .S files are all compiled using standard c/c++/assembler conventions, while the .pde and .ino files are concatenated and (potentially) get special preprocessing and automatic #includes. Which is just a separate makefile rule, really, although the "preprocess" function doesn't exist. While there's no big reason not to make .pde files have their own #includes and prototypes so that the preprocessing isn't needed in an XCode environment, excluding the processing of .pde/.ino files from your Xcode processing makes SW developed there "gratuitously incompatible" with the Arduino environment.

It is (I claim) desirable that the XCode Arduino developer be able to pack his Arduino project into a .zip file and ship it to an Arduino IDE user, where it should compile without any changes. (I suppose that the zip file in question could be a separate XCode "target", but that seems to be unnecesarilly complicated.)

Easily solved by the typical XCode user. I don't think you're properly visualizing the level of cluelessness of the would-be consumer of a pre-made Arduino sketch. "rename main.cpp to foo.pde in a directory name foo, and put all the other file there too" just has SO many things that could go wrong.

To me, it seems this point of view is a little bit overly cautious towards the "beginner Arduino User". We were all beginners at a certain time and I think this little challenge of renaming a main.cpp file into a project_folder_name.pde file is only a small step to make you learn something new. Compared to learning about pointers, inheritance or even functions, renaming a file seems like a piece of cake. (mmm.. cake :-))

Before I started this effort to try to make an Arduino project with XCode, I had no knowledge at all about makefiles. Just by doing this I already learned so much about this completely new topic. It's fun! And it's a great way to learn too: trying to take this next step and looking through other people's code trying to make sense of it...It's great that the Arduino IDE is working so good "out of the box" so beginners can get their hands dirty immediately. But at a certain point, if you want to create more complex programs you'll want to learn about classes, pointers, etc and then it is actually a good thing to have a more advanced software community that can happily program in their "professional" IDEs and assist those people.

But what if the Arduino IDE would allow correctly formatted C/C++ code? Then there would be no compatibility problem anymore, right?

I feel we're getting a little bit off topic here.. this thread was going to be about getting XCode to compile Arduino projects I believe.So let's first get the templates ready for XCode 3.2.x and XCode 4.x and all the different boards, get them properly working for everybody and then worry about the potentially more complex problem of compatibility with the Arduino IDE.

If you have any suggestions on how to solve this problem, let's hear 'em! Maybe there is a very simple solution that I'm not seeing right now... like a simple text file included in the XCode template that explains what to modify for use in an Arduino IDE and vice versa?

That's a very good question. I suddenly realize that I've made this not so user friendly.Basically, what you need to do is find the variables CPP_LIBRARIES, INCLUDE_LIBRARIES and CXXSRC and add some things.

I will update the github repository as soon as possible with a new makefile and build settings that allow you to add libraries of your own without needing to touch the makefile. I will report back here when that's uploaded to github.

Meanwhile, here is an example of how you could modify the makefile:Make sure not to use ~/ for your home path, but the full name : /Users/yourUserName/ ... (because of a mistake I made)

# Here you add the paths to the folders that contains the cpp files of your libraries:OTHER_LIBRARIES = /Users/yourName/Documents/arduino_sketchbook/library1 \ # << backslash means "continue on next line"/Users/yourName/Documents/arduino_sketchbook/library2

# make the correct paths for the librariesINCLUDE_LIBRARIES = $(addprefix -I$(LIB_ROOT)/,$(LIBRARIES)) INCLUDE_LIBRARIES += $(addprefix -I,$(OTHER_LIBRARIES)) #<<<<<<<<<<<<<<<<<<<<<<<<<<<< add this line

I have uploaded a new version of the XCode3.2 template to github. The adding of external libraries has been simplified a lot and it has (hopefully) clear instructions now in the README file. Get it here: https://github.com/timknapen/Arduino-With-XCode and let me know what you think :-)

I have also made a working XCode 4 project in Lion, but it seems that making templates is still a little too obscure. I haven't done too much research yet (just installed Lion today) so it might not be as hard as it looks.

At the moment, I think it might be better to not go for a project template, but do it the way openFrameworks does it: creating a blank project that has everything setup and just copy the whole project folder to start a new Arduino project in XCode 4

I've added a first version of an example XCode 4 project to the github repository.Not a template, a blank project that you can copy and start from. When documentation on XCode 4 templates starts appearing I might have a go at it...

I'm not working in OSX Lion myself, so I'm going to wait for complaints/suggestions before I continue working on the XCode 4 project.

What we "need" is a command-line mode of the Arduino app that does the Arduino-style preprocessing on a set of .pde (or .ino) files.Having to figure out exactly what it does (slightly differently) with each Arduino release is a pain, and makes implementing Arduino program builds in other IDEs an exercise in chasing not-fully-documented behaviors. :-(

I fully agree. Learning Makefile is just horrendous.

Another big benefit is to ensure consistency of the code between the Arduino IDE and alternative IDEs.