Go Down

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

HaakonStorm

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 :)
All the best, //Storm

avenue33

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!



HaakonStorm

@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
Code: [Select]
pinMode(13, OUTPUT);
to setup(), and changed loop() to
Code: [Select]

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
Code: [Select]
PORT = /dev/tty.usbmodem*
makes the TX/RX flash as it should, but this line reads
Code: [Select]
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.

avenue33

#63
Jan 19, 2012, 12:31 am Last Edit: Jan 19, 2012, 12:42 am by avenue33 Reason: 1

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.



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



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...

timKnapen

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:
https://github.com/timknapen/Arduino-With-XCode

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

best,
tim.

avenue33


avenue33

It works but:

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

and

•   No template

timKnapen

#67
Jan 19, 2012, 11:45 pm Last Edit: Jan 20, 2012, 12:00 am by timKnapen Reason: 1
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
Quote
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?

timKnapen

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.

avenue33

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?

timKnapen


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...

Code: [Select]

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?

Quote

Could Storm help us on the Xcode issues?

fingers crossed! :-)

best,
tim.

timKnapen

Xcode 4 + makefile + code completion = trouble.
I have found this nice post on stack overflow and will try this next:
http://stackoverflow.com/questions/8726869/xcode-4-external-build-system-code-completion

... and so I did:
https://github.com/timknapen/Arduino-With-XCode/tree/master/Arduino/ArduinoOnXCode4_3
:-)

It's a very stupid workaround, but it seems to be working!
I hope you guys have the same experience...

good night,
tim.

avenue33

Please find the new release 4.3c

Declare your library repository
    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/
        ~ is accepted

Add a library
    1. Click-and-drop the folder where the .h and .cpp files are into the User folder on the left pane
    2. Uncheck Copy items into destination group's folder
    3. Select Create groups for any added folders
    4. Press Finish
    5. Add the #include statement to the sketch
   
Other items
    New groups
    Simplified project without unnecesary Sketch.h
    Renamed Index (false target) for code sense
   

To Do
    Open serial console after uploading
    Close serial console before building and before uploading
    Hints
        screen $(PORT) 19200

... and obviously a template!

@Tim: I've done a pull request!

Enjoy ;)

timKnapen

Hey Avenue,

What is a "pull request"? I don't get all that git at all..

I will check your version out when I get back to the Lion machine... maybe I can steal some of your ideas :-)

oy!
tim.

avenue33

A pull request is just I'm asking you to include in your repository my updated code.

Go to your repository, click on Pull Requests: my update is there.

Review the code and accept/refuse to update with the appropriate button.

It makes release management easier.

Go Up