Go Down

Topic: Arduino on Xcode Project — Official Thread (Read 321269 times) previous topic - next topic


Hey Avenue33 (olivier?)

I was looking through your version of the XCode project on github and noticed that you have a way to allow paths to use '~/' for the user path. How did you manage to do that?
When I was testing this, my makefile didn't understand ~/ as the current user's home path??

Everyone else:
I will continue making a bit of a mess of the repository for a while as I start learning git and try to set my repo up as a collaborative project.
This repo only makes sense if all of you can update to it and add your improvements. 
I think I should split the repo up into 4 projects because of the changes introduced in Arduino 1.0 :

1) Arduino0022OnXCode3 : Template for Arduino 0022 with XCode 3.2 on OSX Snow Leopard
2) Arduino1OnXCode3 :      Template for Arduino 1.0 with XCode 3.2 on OSX Snow Leopard
3) Arduino0022OnXCode4:  Empty project for Arduino 0022 with XCode4 on OSX Lion
4) Arduino1OnXCode4:       Empty project for Arduino 1 with XCode4 on OSX Lion

What do you guys think? Does this make sense? I would split it up like this because making an XCode project that works with both Arduino 002x and Arduino 1.0 will become quite complicated. There are too many renamed files...
Or should we just abandon 0022 and go ahead with the latest and greatest version of Arduino.. ?



Jan 23, 2012, 03:40 pm Last Edit: Jan 23, 2012, 03:42 pm by avenue33 Reason: 1

Yes, my first name is Oliver, and Rei Vilo in reverse ;).

Here's the trick for the ~:

1. Select Project > Build settings    
2. Click on Add build setting > Add user-defined setting
3. Add new key = SKETCHBOOK_PATH with value = ~/Documents/SketchBook/ ( ~ accepted)


Or should we just abandon 0022 and go ahead with the latest and greatest version of Arduino.. ?

MPIDE is still on release 0022, so I'd like to continue with this release.

Most of the issues we're presently facing aren't Arduino- or chipKIT-releated.

They're Xcode 4-related, as code sense, serial console and template.


Hey Olivier,

"verlan" right? this much french I know :-)

I still don't get it, from your picture I can see how you add it in XCode, that's not the problem. My problem was that the makefile didn't understand ~/ and couldn't translate it into /Users/YourUserName/
That's what I'm curious about!

oh and I think I'll be able to fix code sense for the Arduino libraries too. I will test & upload it as soon as I can get to the Lion machine.



The makefile:

Code: [Select]
# print info
@echo "------------------------ some info for debugging ------------------";
@echo "\nUsing AVRDUDE: " $(AVRDUDE);
@echo "\nUsing board: " $(BOARD);
@echo "\nUsing BF_CPU: " $(BF_CPU);

The result:

------------------------ some info for debugging ------------------
Using AVRDUDE:  /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude
Using board:  Arduino_UNO
Using BF_CPU:  16000000L
Using SKETCHBOOK_PATH:  /Users/OlS/Documents/Arduino/_Projets


oh right, I just checked my makefile and it appears that the problem was this:


somehow by doing the $(addprefix ..) doesn't expand the ~/ in LIBRARY_PATHS.
Just passing a build setting as a single variable does expand the ~/
I'm cleaning that up in my makefile, because ~/ is awesome! :-)



Jan 24, 2012, 01:42 am Last Edit: Jan 24, 2012, 02:50 am by timKnapen Reason: 1
Hi all,

I think we've finally managed to have code completion working decently on Xcode 4.

The updated project is here:

This is the 'experimental' branch. I will merge it into the main branch once I get some feedback from other people that can get it to work too.

There is a little trick to it:
You need to add all the sources ( .c, .cpp and .h files) to the 'Compile sources' build phase of the Fake Target. This fake target is only used for triggering the code completion in Xcode 4.

In the project navigator click on your project > Targets > fake target > build phases > expand "Compile sources"
press the "+" button at the bottom and in the list that pops up, just select all your .c, .cpp and .h files.

To add your own libraries, just drag them into the source tree with these options:

You will still have to add the path to those files in the build settings

hope this helps,



Great work! Thanks.

In the screen-shot you supply, Serial.print is still in black :(


I posted two suggestions on the GitHub issues list:

#3-- Codesense not working all the time in Xcode 3.2
Serial.print() is still in black  :~

#4-- Auto-Launch of the Console
Serial console parameters
Close serial console before upload OK
Open serial console after upload Error: screen /dev/tty.usbmodem641 -b19200 Must be connected to a terminal.
How to make the connection with the terminal?

#12-- User libraries easy declaration
Just type the name of the folder of your library

  • code: #include "Serial_GP"

  • makefile: USR_LIBRARIES_LIST  = Serial_GPS


Jan 24, 2012, 03:09 pm Last Edit: Jan 25, 2012, 12:39 am by timKnapen Reason: 1

In the screen-shot you supply, Serial.print is still in black :(

Look here: :-)

Latest changes for XCode 4 to be found here:

Any more code completion that is not working?


Hi all,

I've secured the xcodeuino.com domain (I considered xcodeui.no for .Norway but relented;) and web
hosting with mySQL databases for a year. I planned to implement it as a Joomla!-site but talking
with a collegue I've decided to use Drupal instead. This means I no longer know
what modules are good or not, so if you have any preferences, let me know.

I'm thinking something like this:
Forums: Drupal Advanced Forum module(s) (screenshots: http://drupal.org/node/867944)
Wiki: demo of the wiki-installation module http://acme.yourbizwiki.com/ (login with test/test!!)
File upload functionality
Unregistered/Registered/Admin/SuperAdmin granularity for permissions

Lets start with just one discussion board, put it on the front page, and go from there
as we build the wiki, coordinate our efforts and get to master how git works with
branching and pulling and requesting :)

If everything goes according to plan, it should be live monday and open for registrations.

Again guys, thank you so much for all the work you've put in to creating makefiles and what not
to get xcode+arduino running together. I'm way behind atm but will get up to speed asap.



Any more code completion that is not working?

That world fine on my MacBook.

Could you please detail how you reach the result? I've already noticed the HEADER_SEARCH_PATHS parameter, but are there other?

Please keep in mind I'm working on a Makefile with MPIDE for Arduimo and chipKIT platforms.

I also posted a new idea worth considering: a cleaner make with a specific directory for OBJ files, with a reference to another Makefile repository.


Olivier et al:

If it isn't too much hassle, I know that myself and many with me would appreciate a lot if
you could do a write-up of what you have learned so far about how this Xcode+Arduino.app setup
works. I'm thinking about a sequential description of how you understand everything runs from
the point to click Build&Upload, what happens with the makefile, documentation about the makefile
and other important knowledge like customizing code completion, syntax coloring et al.

I'm thinking this can be the starting point for a page in the upcoming wiki. We can divide it
into the different phases of compiling and uploading.

We can also start a wiki page documenting how to use git for this project in particular; how to
clone, branch, pull requests and merge. I'm still not sure how merge works with conflicting
parts of the same files (say, the .xcodeproject file) and not overwriting other important changes.
I know diving into many smaller files are key, as always, but with Xcode projects some files are
unavvoidably monolothic.

Also, how does the serial monitor work with our setup? I see you use 'screen ...' - is this the
usual screen command I use when I start shell scripts and irssi on remote servers so I
can reconnect to them later?

Maybe it's an idea to hack a quick Cocoa app or script that handles/starts the serial monitor automatically
for the user?

I've also ordered the WiFly wifi shield from Sparkfun.com so my arduino can speak tcp/ip
with the world. Do you guys have any experience with this, or have any other wifi shield
to reccommend?


Regarding versions: as Olivier use a different and more powerful Arduino board that
isn't fully compatible/running to Arduino 1.0 libraries yet, we'll have two parallell
projects running (or more). For myself I'm primarily interested in Arduino 1.0 + Xcode 4.2
as I'm just recently come aboard and might as well start with the most recent iteration of both.

Tim: How does A*.app 1.0 seem to have changed from 022?


Could you please detail how you reach the result? I've already noticed the HEADER_SEARCH_PATHS parameter, but are there other?

Hey Olivier, my guess is that this should work fine on mpide too, as  long as you have Arduino.app installed. Unless Mpide has a lot of functions that are not in Arduino? Anyway it is only for syntax coloring and code completion, it will not affect your build.
IF mpide is not following the arduino conventions, it should be another project anyway, we can't make one XCode project for every flavour of Arduino-style AVR programming, right? Better make a specific project that bases its concepts on the Arduino project.

How does it work? "Serial" is defined in HardwareSerial.h, but only when certain macros have been defined. Those are defined in io.h.
Those macros get defined depending on a macro that defines the arduino board you're using.
So when you pick your board inside the Arduino.app before compiling, it adds a macro that defines your board. For example: __AVR_ATmega168__ . When this is defined, io.h can then load the correct io header for that specific board and the serial communication can get put together correctly.

I have just set __AVR_ATmega8__  in the build settings for the fake target, because for our purposes it doesn't really matter what board the fake target thinks it is building for. (not really sure about this)

While looking through all this, I noticed that a lot of stuff in the Arduino .cpp and .h files depends on inttypes.h, stdlib.h, stdio.h etc..
Just to be sure, I included the ones that avr-g++ uses in the header search paths.

I thought about moving the Arduino group to the header search paths too, but I think you sometimes want to check them for reference...


Go Up