Arduino on Xcode Project — Official Thread

Elijahg:
Unfortunately your template doesn't seem to work for me without quite a few tweaks. I have Arduino 1.0. I've followed all the steps in your guide, but I firstly get an error in Step1.mk "Error: no application found". That's because in Step1.mk ARDUINO_APP = /Applications/Arduino23.app when it should be just Arduino.app.

Upon fixing that, I then get
Sometimes I get an error that the compiler can't locate "pins_arduino.h". Doing the following fixes both errors.
In Step1.mk, change

Fixed. Arduino.mk now points to Arduino.app.

Elijahg:
Also, inside Arduino1.mk "APP_HEADER = WProgram.h" appears to be wrong, as Arduino 1.0 uses Arduino.h.
APPLICATION_PATH in the same file assumes the Arduino 1.0 is called "Arduino1.app" also.

Fixed.

Elijahg:
Most people won't have a number in their Arduino app name, it'll just be the default Arduino.app.

Fixed.
Arduino.mk addresses Arduino.app.
Arduino1.mk and Arduino23.mk makefiles are supplied for convenience.

Elijahg:
CORE_LIB_PATH should have a lower case "Arduino" in the path, as it's lower case in the filesystem (in Arduino 1.0 at least). Currently, this won't work on case sensitive filesystems. USER_LIB_PATH should have a lower case "libraries".

Fixed for SketchBook/Library or library.
Fixed for /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino
By default, OS X is case insensitive.

Elijahg:
If leaving the target on All, an error "/bin/sh: Builds/nil: No such file or directory" occurs. After using other targets, the Builds folder is created so the error goes away. A Builds folder should be in the file template.

Fixed.

Elijahg:
main.cpp in the project template should be Arduino.h not WProgram.h. Same in the C++ and Library file templates.

Actually, the #include in main.cpp is used to activate code-sense.
Fixed in the Library file template.

I hope to release the updated version soon.

Thanks again for the detailed feed-back.

Feel free to explore Xcode 4.3-related issues!

avenue33:
By default, OS X is case insensitive.

It is yes, but it's always best to write code that handles unexpected or unusual conditions rather than just failing :slight_smile:

Actually, the #include in main.cpp is used to activate code-sense.
Fixed in the Library file template.

With WProgram.h included in main.cpp code sense doesn't work for me. If I change it to Arduino.h it works right away. The default .pde file includes WProgram.h too when it should again just include Arduino.h

There's a small problem with uploading too, for some reason the port for AVRdude to use gets lost somewhere. Changing AVRDUDE_PORT in Avrdude.mk to $(BOARD_PORT) fixes that.

Thanks again for the detailed feed-back.

No problem, thanks for the template!

Elijahg:
There's a small problem with uploading too, for some reason the port for AVRdude to use gets lost somewhere. Changing AVRDUDE_PORT in Avrdude.mk to $(BOARD_PORT) fixes that.

That's strange, AVRDUDE_PORT is defined in Avrdude.mk by:

AVRDUDE_PORT      = $(firstword $(wildcard $(BOARD_PORT)))

with BOARD_PORT defined in Arduino UNO.xconfig by

BOARD_PORT = /dev/tty.usbmodem*

or in Step1.mk otherwise by

ifndef BOARD_PORT
    BOARD_PORT = /dev/tty.usb*
endif

Arduino UNO.xconfig has priority over Step1.mk.

avenue33:
That's strange, AVRDUDE_PORT is defined in Avrdude.mk by:

AVRDUDE_PORT      = $(firstword $(wildcard $(BOARD_PORT)))

with BOARD_PORT defined in Arduino UNO.xconfig by

BOARD_PORT = /dev/tty.usbmodem*

or in Step1.mk otherwise by

ifndef BOARD_PORT

BOARD_PORT = /dev/tty.usb*
endif


Arduino UNO.xconfig has priority over Step1.mk.

Board_port is pulled from the config file fine, but "$(firstword $(wildcard $(BOARD_PORT)))" seems to return nothing, making AVRDUDE_PORT blank. Without $(firstword $(wildcard it works fine.

Hi again, I've discovered another problem, but unfortunately my makefile writing skills aren't up to scratch to fix this one.

For some reason the Step2 makefile is losing the USER_LIBS_LIST. USER_LIB_PATH works for me when in Arduino.mk I change

USER_LIB_PATH = $(wildcard $(SKETCHBOOK_DIR)/libraries)

to

USER_LIB_PATH = $(SKETCHBOOK_DIR)/libraries

However, for some reason USER_LIBS_LIST is always "0" in the debug info. Any ideas? The only way to get non-core libraries to compile is to enter their full path into the source.pde. Thanks!

Just open makefile

# Libraries
# ----------------------------------
# Declare application Arduino/chipKIT/Wiring and users libraries used 
# Short-listing libraries speeds-up building
# Typing = 0 takes none
# Otherwise, all will be considered (default)

you can define which Arduino/chipKIT/Wiring libraries you want

# List Arduino/chipKIT/Wiring libraries here 
#

as well as which users libraries

# List users libraries here 
#

Those parameters are intended to avoid compiling all the libraries each time and thus, speed-up the process.

Ah that's great, thanks :slight_smile:

Perhaps it'd be better to have an environment variable set in Xcode defining whether you want to compile user libraries or not, would be much easier than changing a list in the makefile. You could have the envar as a list of user librares too.

Feel free to skip APP_LIBS_LIST and USER_LIBS_LIST from Makefile and add them to Project > Project > Build Settings > User-Defined.

The real challenge is to obtain documentation about Xcode inner structure and keywords to improve:

  • the template sets the sketch as c++ code and not plain text, for code-sense
  • the template populates the Sources List for code-sense
  • instead of having the serial console in a separate Terminal window, integrate it in Xcode debug pane
  • ...

New releases add Wiring and LaunchPad support.

embedXcode • Apr 05, 2012 release 7 • Wiring and LaunchPad platforms added
mpideXcode • Apr 05, 2012 release 10 • Wiring and LaunchPad platforms added

Code is here and documentation there.

Both build and upload have been successfully tested on Wiring S and LaunchPad msp430g2452 boards.

Energia is the Processing-based IDE for the LaunchPad platform.

Critical Decision Ahead

Most of the open points on embedXcode are about Xcode, especially keywords on the template.

Despite numerous calls for help, they're still unresolved. The Xcode template remains undocumented and there's no sign of openness from Apple. Apple seems to restrict Xcode to OS X and iOS platforms only.

So I'm considering to change for another IDE, with NetBeans as most probable solution. It's open, and documentation is available.

What do you think?

There are people attempting to unravel the template format (why Apple had to change it in Xcode 4 to this weird new system we'll never know) for coding other projects too. You aren't alone in trying to decipher it, but only asking for help via the Arduino on Xcode project means the audience is pretty small. I'm sure someone will figure it out (or it'll get leaked from Apple) sometime.

You're right that Xcode is really designed for OS X and iOS, Apple has little interest in supporting other languages/platforms. Despite its limitations though, I'd personally rather use Xcode. NetBeans is Java, which is usually pretty clunky and un Mac-like. I don't have experience with anything but the Arduino IDE, and Xcode on the Mac however.

Elijahg,

You're right about selecting the right channel for the right audience.

I'm posting on both Xcode-related forums —of which Stack Overflow for very specific questions about the Xcode 4 template— and embedded computing related forums.

The idea is Arduino users may be interested in using Xcode and Xcode experts may have some tricks to exchange.

Thanks to this strategy, the Wiring and LaunchPad platforms are now supported by embedXcode. I hope adding more platforms may help raising interest on this project.

There are so many things one could dream about: built-in serial console, integrated help, debugging, closer integration of the tool-chains, ...

Please find the new releases for

embedXcode • Apr 16, 2012 release 9 • Code-sense reference defined by selected board
mpideXcode • Apr 16, 2012 release 12 • Code-sense reference defined by selected board
Installation Guide • Apr 16, 2012 release 6 • General update

All the manual settings are due to unknown template keywords. Your help is greatly appreciated.

Documentation is here and code is there.

embedXcode now supports Maple!

embedXcode • May 23, 2012 release 10 • LeafLabs Maple implementation
mpideXcode • May 23, 2012 release 13 • LeafLabs Maple implementation
Installation Guide • May 23, 2012 release 7 • LeafLabs Maple implementation

The Maple reset script —which sends control signals over the USB-serial connection to restart and enter the bootloader— is written in Python and requires the PySerial library:
• Read the instructions at Maple | LeafLabs and
• Download PySerial library from pyserial · PyPI.

Full documentation and download are available here.

Enjoy :slight_smile:

Please find the new releases of

embedXcode • Jun 03, 2012 release 11
mpideXcode • Jun 03, 2012 release 14
Installation Guide • Jun 03, 2012 release 8

As embedXcode manages multiple platforms, including the right libraries and dealing with syntax specificities are two cumbersome challenges.

Until now, the platform identification was solely based on the MCU, resulting on lengthy #if #elif #else #endif statements.

Now, embedXcode brings a new approach based on the IDE.

The Arduino, Wiring and Maple IDEs set an environment variable for the tool-chain.

For example, Arduino defines ARDUINO=100 and pass -DARDUINO=100 on to gcc, g++ and alike, Wiring sets -DWIRING=100 and Maple -MAPLE_IDE.

So the code is fully compatible between embedXcode and those IDEs. This new approach brings more compact and easier to read code, and doesn't require maintenance at code level when a new MCU appears.

This new IDE-based approach is optional, as not all IDEs include this approach. Let's mention Energia and chipKIT MPIDE, and hope they consider it!

As always, full documentation including features, tutorials, installation guide and code, is available at embedXcode website.

Enjoy :wink:

I'm working on the next release of embedXcode. I plan to integrate an automatic documenting feature.

After having reviewed HeaderDoc, doxygen and appledoc, I picked doxygen.

Integration with Xcode is the main challenge. The idea is to select a specific target to build the documentation, obtain a PDF and integrate a codeset Xcode could use.

There's still a lot of work to do.

Stay tuned :wink:

Please find the new release of embedXcode with the implementation of the self-documentation.

embedXcode • Jun 14, 2012 release 13
Installation Guide • Jun 14, 2012 release 9

Just add to your code and launch the Document target:

A help document is generated and closely integrated in Xcode.

Quick Help provides details on documented functions:

As always, learn more and download from here.

New version 14 of embedXcode brings a significant improvement on the size of the HEX and BIN files over the

embedXcode • Jun 25, 2012 release 14 • HEX and BIN files size optimisation

Sizes are now close to and even better than those obtained with the corresponding IDEs.

All measures are in bytes.

As always, learn more and download from here.

Hey everybody,
I believe the arduino on Xcode project is just awesome, and as i have a pretty big arduino-project coming up for myself,
i wanted to switch to Xcode for the programming part, But:

On Lion, the developer-folder changed, it is now located in Xcode/contents/developer

So now I'm not sure where to put the embedxcode template files???

i do believe here like in the photo? am i right? because there are other Xcode/template/file_temp.... in the platform-direction!!

might be a dumb question but thanks anyway!

Please refrain from modifying the Xcode directory! This is potentially dangerous!

Instead,

Installation Guide and User Manual:
1.4. Install the Template
Now, the template can be installed:
Check and create ~/Library/Developer/Xcode.

Copy the folder Templates into ~/Library/Developer/ Xcode

I wrote an Installation Guide and User Manual. I hope it's clear enough.

Enjoy :wink: