Arduino on Xcode Project — Official Thread

yes, the newest version (1.0) has changed quite a bit I think.

An example from the release notes of Arduino 1.0:

The WProgram.h file, which provides declarations for the Arduino API,
has been renamed to Arduino.h. ...

Your problem is probably related to that.

Just download the 0022 version and see if that works for now. I'll get the a working project with the new Arduino version up on github after next week.

best,
tim.

Thanks Tim, I'll take a look at that trying to solve this issue. I hope so.

Thanks, I'll let you know :slight_smile:

Tim,

On Xcode 4.2.1 running on Mac OS X 10.7.2 with Arduino 0022, I have the following error message

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin//avr-ar: bin/core.a: No such file or directory

I haven't installed the FTDIUSBSerialDriver_10_4_10_5_10_6 since it isn't required on OS X.

Any clue?

Log.txt (76.5 KB)

Hey Avenue,

I think that's a big "whoops" on my part...
there is one "/" too many in

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin**/**/avr-ar: bin/core.a: No such file or directory

so my guess is that the AVRDUDE_DIR variable in the makefile is wrong. It was

AVRDUDE_DIR = /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/

and I changed it to

AVRDUDE_DIR = /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin

You can adjust it yourself or get the updated one from github.

let me know if it works, I can't test on Lion right now.

best,
tim

Never mind about the oops!

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar: bin/core.a: No such file or directory

Unfortunately, the bin/core.a remains orphan.

Trying to get things going. I am running...

  • Lion 10.7.2
  • Xcode 4.2.1
  • Arduino Version 0022
  • timknapen-Arduino-With-XCode-08ce0ae
  • Duemilanove 168 (also have a Mega and a few clones)

Sample project builds and upload fine. I started a project that uses the Wire library and get...

bin/core.a(Wire.o): In function TwoWire::send(unsigned char)': Wire.cpp:(.text._ZN7TwoWire4sendEh+0x3c): undefined reference to twi_transmit'

plus a couple more similar errors. It appears twi.h can't be found. I've tried changing #includes from angle brackets to quotes (and visa versa), moving the twi.c and twi.h out of the "utility" folder and into the same folder as wire.h and wire.cpp, changing stuff in the compat folder (#include "util/twi.h" to #include "utility/twi.h", etc, etc, etc.

Boy there are a bunch of copies of the include files inside the Arduino app. One thing I noticed about the "starter folder" from GitHIb: There references to "arduino" and "libraries" in the project tree were bad (red) so I deleted them and re-added them from the Arduino app. Was this the right thing to do?

Chasing my tail... Any ideas?

The bin/core.a seems to be a source of troubles...

I hope timKnapen could consolidate all the feed-back, fix the issues and release a new version!

Good luck timKnapen :slight_smile:

haha thanks Avenue,

I am following this conversation, but I am traveling without a computer that runs Lion. I'll be able to fix all these issues in two weeks.

Also thank Swany and gianmarcoodorizzi for all the great feedback!

best,
tim.

Bonjour Tim,

No problem.

I've played with the Visual Micro, an Arduino plug-in for Microsoft Visual Studio and it's really nice.

Back to Xcode, the 4.2 release looks really buggy: I had many "Xcode has crashed" messages when I was coding some plain C++.

I'm considering downgrading to the previous stable release Xcode 3. Other candidates are Eclipse and NetBeans. Both have a dedicated Arduino plug-in available.

Since the makefile is too cumbersome, have you considered Ino? It's a command-line version of the Arduino pre-compiler / compiler. It works fine on my MacBook.

Best regards,

Hi all, just wanted to say I'm ALL IN on your Xcode 4.2.x + Arduino efforts!

I'm currently studying computer science at University of Oslo, and one of my topics of
study right now includes a project based on Arduino. To check out what previous
students of this topic have done with Arduino, see: http://sonen.ifi.uio.no/soneprosjekter
(it's in Norwegian, but there's plenty of pictures and video).

I worked as an OS X Server consultant for some years, before I decided I wanted to
move on and go full time as a developer and so went back to
school to learn computer science proper. In particular: iOS, OS X and Arduino projects.

SO :-), I'm very motivated to help out as best I can to get a decent environment for
doing Arduino projects on Xcode 4.2.x up and running. For now I'm reading everything
I can find to educate myself; starting with cloning Tim's excellent git repository to
get everything running. (Thanks, Tim!)

I'm determined to study and do whatever it takes to master Xcode and Arduino, in
particular using the iPhone and iPad to communicate with the Arduino over TCP/IP.

I've got the feeling there must be thousands of people like us around, wanting to
use Xcode for serious Arduino development. So how about we organize ourselves in
some way and launch arduinoandxcode.com, xcodeuino.com or similar? I can put up a simple Joomla-site
in two nights with the primary resources we need: a forum, a news blog, a downloads
section. We could start by setting up a Yahoo Group, having good experiences with it
from past projects, primarily the 'email group' functionality. Emails to xcodeuino@yahoogroups.com from
registered users go to all other registered users with a [xcodeuino] tag in the email header,
just like good ole UseNet used to do. Very simple and very clean.

Let me know what you guys are thinking :slight_smile:
All the best, //Storm

God kveld Storm,

That's great news.

I started the project a long time ago —July 2010— before joining Tim's project late 2011.

Compiling does work under Xcode 4.2, see the project available at https://github.com/rei-vilo/Arduino-With-XCode. The makefile is stable. There's only the user library point to check.

Actually, most of the problems come from Xcode:

• No console
• No tooltips for user created items
• No syntax colouring for user created items

and

• No template

I managed to run Jantje's plug-in for Eclipse but I didn't succeed in installing the plug-in for NetBeans.

Another option I tried is Ino, a command-line compiler for Arduino sketches.There are presently issues with the user's libraries hosted in the Sketchbook/Libraries folder.

I also use the chipKIT UNO32 board, which requires the PIC32 tool-chain. So I'd like to be able to compile for the two platforms.

So making Arduino usable under Xcode is going to be mainly a Xcode 4.2 issue! But it will open the door to all iOS devices.

Back to the project, gathering and organising the resources are key. I fully agree with you on having a shared website to give maximum visibility to the project.

So let's go!

@avenue33,

thanks for all the work you've put in over the years. Big up!

A common web site for Xcode, Arduino and iOS development will be nice. I'll get to
work as soon as the workload at Uni permits. Would be nice to get more
peoples opinions as well before speccing the requirements for the site, maybe
even get more people aboard our project.

Have you been looking into what needs to be done getting everything up
and running with Arduino 1.0?

I had to downgrade to the 022 release to get the Xcode project to compile.
Even so, I'm having problems getting actual code running on the Arduino. Everything
appears to upload fine, but my sample code doesn't run. I added

pinMode(13, OUTPUT);

to setup(), and changed loop() to

digitalWrite(13, HIGH);   // set the LED on
delay(100);              // wait for a second
digitalWrite(13, LOW);    // set the LED off
delay(100);              // wait for a second

but the on-board LED doesn't flash. Uploading the same sample code from Arduino.app
produces the expected results.
The .xcconfig line

PORT = /dev/tty.usbmodem*

makes the TX/RX flash as it should, but this line reads

PORT = /dev/cu.usbmodem3d11

in Arduino.app -- is it vital that these match? I've tried changing to match but get the same results.

Also, I know very little C++, only C and Objective-C, so I need to read up on C++ in order
to get up to speed. I didn't even know it was possible to use C++ with the Arduino.

HaakonStorm:
Have you been looking into what needs to be done getting everything up
and running with Arduino 1.0?

Yes, I did.

Please refer to this page with 2 must-read articles!

It implies rewriting all my libraries. So I'm waiting for MPIDE to be on release 1.0 to upgrade.

I can't maintain two different versions for each of my libraries.

HaakonStorm:
I had to downgrade to the 022 release to get the Xcode project to compile.
Even so, I'm having problems getting actual code running on the Arduino.

Are you playing with this example https://github.com/rei-vilo/Arduino-With-XCode?

It works fine on my MacBook / Xcode 4.2 / OS X 10.7.2

HaakonStorm:
Also, I know very little C++, only C and Objective-C, so I need to read up on C++ in order
to get up to speed. I didn't even know it was possible to use C++ with the Arduino.

Actually, the language used in the Arduino IDE is a C / C++ dialect. If you're fluent in C, C++ shouldn't be a problem.

Keep in mind the main benefit / drawback of the Arduino IDE is to hide all the pre-processing work before building and linking.

So one of the topic to discuss is to define how much the Xcode implementation hides.

Let's keep a little for tomorrow...

Hi All,

I've been away from the Lion machine for a while, but I have updated the Xcode 4.2 project now with all the fancy new features I had added to the Xcode3.2 version.

Check it out at:

I hope this resolves all the problems with Xcode I've been hearing about the last weeks.

best,
tim.

Tom,

Have you included my pull request?

It works but:

• No build report
• No console
• No tooltips for user created items
• No syntax colouring for user created items

and

• No template

Hi,

The build report should be there, XCode 4 actually generates a build log for every time you compile. It's one of the buttons next to the "Project Navigator" button. (above the source tree)

With

No tooltips for user created items
No syntax colouring for user created items

you mean code completion / code sense for the classes you add, right?
This has been bothering me too... there's really no use working in XCode when you don't get those features...

I'm still on Snow Leopard because I think Lion sucks, so I work with XCode 3.2 and everything works nicely there (see attached image) :

I don't really understand why the code completion would fail on XCode 4, what could be different from the one that I use?

Screen shot 2012-01-19 at 21.56.25.png

oh now I get it! by "no console" you mean "no serial communication", right? I thought you meant built output... sorry!

I never experienced this as a problem. The Arduino Serial monitor does everything it needs, especially now you can decide the line endings...
Before they added this feature to the Arduino IDE I actually had written my own serial monitor app that did the same thing, but now I never use it anymore, just because of this one little feature.

I also don't see why Xcode would need to do this.

I'm going to take a look at that code completion stuff now...

best,
tim.

Hi Tim,

No problem. Yes, I mean no serial communication.

Problem is, if I open Terminal or whatever communication app, I need to close it before uploading to the Arduino, otherwise there's a conflict and a message pops-up "Serial port already used."

One idea could adding to the Makefile
• "screen $(PORT) 9600" after uploading
• and for safety reasons, "kill screen" before compiling.

Yes again, I mean code completion and code sense.

I tested with Xcode 3 and code sense works as you show it.

With Xcode 4, code sense and code completion don't work for the classes, variables, functions I add.

Strange enough, opening the same sketch as a plain C++ Xcode project does provide code sense and code completion.

So there's a parameter somewhere to fix.

Or, it Xcode bugged?

Could Storm help us on the Xcode issues?

avenue33:
No problem. Yes, I mean no serial communication.

Problem is, if I open Terminal or whatever communication app, I need to close it before uploading to the Arduino, otherwise there's a conflict and a message pops-up "Serial port already used."

One idea could adding to the Makefile
• "screen $(PORT) 9600" after uploading
• and for safety reasons, "kill screen" before compiling.

right, didn't think of that. That might be a good idea...
Maybe we should have build settings flag then, I can imagine it being pretty annoying to have this pop up every time when you're working on a project without serial...

With Xcode 4, code sense and code completion don't work for the classes, variables, functions I add. 

Strange enough, opening the same sketch as a plain C++ Xcode project does provide code sense and code completion.

Did the same test just now, it seems that Xcode has no problem with C++, but I can imagine it needing the compiler for code completion...
and then the makefile is maybe a step too far for Xcode?

Could Storm help us on the Xcode issues?

fingers crossed! :slight_smile:

best,
tim.