Arduino on Xcode Project — Official Thread

Well, it seems your project is having some issues even in the Arduino IDE.

How complex is your project?

The sketchbook folder is the place were you place a link to the libraries you've developed.

Please refer to section 3.3. Add User's Libraries on pages 25 et sq. of the User Manual.

it's really just the test project that appears when you create a new embedxcode project. I haven't changed a line of code and just wanted to try if it compiles, at all... :~
maybe I should try a regular c++ project to see what's wrong with the environment?

Which release of embedXcode are you using?

Which release of the Arduino IDE are you using?

Is the Arduino IDE installed on the folder /Applications?

Current version 17 of embedXcode doesn't invoque any HardwareSerial in the default sketch.

According to the messages, it seems Arduino 23 and 1.0 are mixed. Best solution consists on deleting the Arduino IDEs and proceeding with a clean install.

Arduino IDE 1.0.2. Just deleted the whole thing (including sketch folder) and reinstalled. (I think it was 1.0.1, before, they must have updated it quite recently).
embedxcode downloaded installer package from your website on 21 oct 2012 (where do I see the version?)
Same result...
I will try a little more over the weekend

Strange indeed. This is the first time such error is reported.

Can I ask you or some other Xcode/Makefile craig again if you have some clues?
I discovered the following:

When I add in main.cpp the full path of BlinkTest.ino (i.e. #include"/Users/myname/Documents/Arduino/BlinkTest/BlinkTest/BlinkTest.ino") the test project compiles in the Arduino IDE.
The warnings are still present. They appear in Libraries HardwareSerial.cpp, Print.cpp and Tone.cpp which are included from a previous compile (although I installed the whole Arduino.app new).
E.g. the last lines of the compiler output before the warnings are:

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=102 \
  -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino \
  -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/mega /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp \
  -o /var/folders/gq/_c97z0614fj267w8732pn4r00000gn/T/build4731805130703822254.tmp/HardwareSerial.cpp.o 
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':

I suspect this may be independent from the build errors in XCode, but on the other hand, I was able to avoid all warnings in previous sketches.

What I also observed: If I insert some rubbish into the main.cpp (either within main{} or outside), it is not picked up during the build target, at all. This can be because it lists too many other errors and parses all includes, first, but may still be a clue.

I still believe this may be some problem with errors due to function overloading which would normally work in C++ (maybe some functions are not interpreted as being part of a class ??)

If I look at the first bit that generates an error:

#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);

#define word(...) makeWord(__VA_ARGS__)

Which is some part of Arduino.h I get the first error in the lower line of uint16_t makeWord saying Declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with and in the line above the error is Previous declaration 'uint16_t makeWord(uint16_t)' here.

I also included in Arduino1.mk the line $(shell env>theEnvironment) and the anonymized result is attached...

Thank you anyone for your help.

theEnvironment.txt (9.91 KB)

I'm sorry not to be able to help you on your specific case.

I don't understand why the blink.ino file isn't inside the folder of the Xcode project:

MyProject/
. MyProject.xcode
. MyProject/
. . blink.ino
. . main.cpp
. . and other files

Please find the new release of embedXcode

  • Oct 26, 2012 release 18 • Support for Arduino Due
  • Oct 28, 2012 release 19 • Support for StellarPad
  • Nov 09, 2012 release 20 • Support for Teensy 3.0

The user manual has been updated too

  • Nov 09, 2012 release 16 • Updated with new boards

Please note the Arduino 1.5, Energia for StellarPad and Teensy 3.0 softwares are in development.

I've tested build, link and upload successfully for all boards except for the Arduino Due I don't own.

Website: http://embedxcode.weebly.com
Download: http://embedxcode.weebly.com/download
User guide: http://embedxcode.weebly.com/tutorial

Enjoy :wink:

ok, I got it to work. (The directory structure was correct, it was just as you mentioned it should be, above, btw).
The problem was that apparently from Arduino 1.0.1 (?) but definitely in 1.0.2 there is a library WiFi in the libraries path in the applications folder, which is included automatically by the makefiles (the APP_LIB_PATH directory seems to be parsed in step2.mk).
Uncommenting the BOARD_TAG and and other variables in the root makefile and running a "make build" from the Terminal gave me that clue.
(btw, is there any way to make XCode give you the verbose build output. It would give better clues, sometimes).

The triggering error was actually

/Applications/Arduino.app/Contents/Resources/Java/libraries/WiFi/WiFiClient.cpp: In member function 'uint8_t WiFiClient::getFirstSocket()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/WiFi/WiFiClient.cpp:177: error: 'SOCK_NOT_AVAIL' was not declared in this scope
make: *** [Builds/libs/WiFi/WiFiClient.o] Error 1

SOCK_NOT_AVAIL is some preprocessor definition in a utility header from that WiFi library, which probably was not parsed.
The duplicates appeared then because it probably messed up the whole preprocessing.

I worked around this by just adding WiFi to the EXCLUDE_NAMES tag definition of step1.mk.
The build target then went straight through without any errors or warnings.

I tried to manually copy the WiFi library to the project folder and included it to all targets in XCode, but that did not work. You probably understand why :wink: and may want to add that library to the next release (or could it not be parsed, anyway?).

Thanks for the tool, it looks great and I will now try out my real projects with it :slight_smile:

I'm glad it works for you now.

matzrh:
Uncommenting the BOARD_TAG and and other variables in the root makefile and running a "make build" from the Terminal gave me that clue.

The BOARD_TAG variable is defined when you select the board on Info pane.
Please refer to section 4.2. Change the Board on the User Manual.

matzrh:
(btw, is there any way to make XCode give you the verbose build output. It would give better clues, sometimes).

All the build, link and upload commands as well as the error messages are available on the Issue navigator.
Please refer to section 5.4. Error Messages on the User Manual.

Xcode is a professional IDE and requires some learning. I strongly recommend Xcode 4 Unleashed by Fritz F. Anderson I bought thanks to contributions I've received.

Please find the new release of embedXcode

Nov 13, 2012 release 21 • Stability enhancement and better information

• Stability enhancement, especially for Arduino Due and StellarPad linking
• Better information in a more structured presentation

As always,

• Website: http://embedxcode.weebly.com
• Download: http://embedxcode.weebly.com/download
• User guide: http://embedxcode.weebly.com/tutorial

Enjoy :wink:

Please find the new release of embedXcode

Nov 17, 2012 release 22 • New Make and Fast optimised targets

embedXcode release 22 includes two new targets: Make and Fast.

The Make and Fast targets feature an optimisation for the build of the foundation libraries.

The new targets are much faster than the corresponding Build and All targets. This is especially important for the ARM-based boards.

Learn more.

As always,
• Website: http://embedxcode.weebly.com
• Download: http://embedxcode.weebly.com/download
• User guide: http://embedxcode.weebly.com/tutorial

Enjoy :wink:

Context - OSX MountainLion, Xcode4.5.2

I have installed embeddedXcode and I can (after some messing about ) generate an Arduino (Uno) project.

I find I cannot compile it here is the error report - the Arduino is not connected and I have not editted the code created

embedXcode

----------------------------------

Embedded Computing on Xcode 4

Copyright © Rei VILO, 2010-2012

Licence CC = BY NC SA

References and contribution

----------------------------------

See About folder

include $(MAKEFILE_PATH)/Avrdude.mk

ifneq ($(MAKECMDGOALS),boards)
ifneq ($(MAKECMDGOALS),build)
ifneq ($(MAKECMDGOALS),make)
ifneq ($(MAKECMDGOALS),document)
ifneq ($(MAKECMDGOALS),clean)
ifeq ($(AVRDUDE_PORT),)
$(error Serial port not available)
endif
endif
endif
endif
endif
endif

I would like to be more explicit - but I simply dont know what to say - except that I would expect it to be able to compile a 'null program'! Earlier attempts encountered other errors ( like 'init()' not defined) - but these have now gone away!

Any help will be much appreciated before I am forced to use VisualStudio!

Thank-you

What target have you selected?

Thank-you for such a quick response!

The only option I can have is All->My Mac 32bit.

The Project Targets/All Build Settings show
Debug Board Port as tty.usbmodem*, and the Debug Board Tag as uno

davidhux:
Thank-you for such a quick response!

You're welcome!

davidhux:
The only option I can have is All->My Mac 32bit.

Strange, you should have also Build, which builds and links without uploading, and many other options as shown is my previous post.

davidhux:
The Project Targets/All Build Settings show
Debug Board Port as tty.usbmodem*, and the Debug Board Tag as uno

I the case your genuine Arduino Uno board —and not a compatible board that may use another driver to upload— is connected, open the Terminal and type

ls /dev/tty.usb*

It might be the serial port is managed by /dev/tty.usbserial* instead of the default /dev/tty.usbmodem*

  • Arduino Uno rev 2 board = /dev/tty.usbmodem411
  • Compatible Uno board = /dev/tty.usbserial-A40084mc

In such a case, just edit the the Arduino UNO.xcconfig file with the USB port.

Thank-you all for your attention.

I have run Blink under OSX Arduino - on port tty.usbmodem*, (As reported by /dev/tty) and no problem.

It would appear that I need to have the Arduino plugged in when I use XCode (?)

I then returned to Xcode and set the Option to BUILD (as suggested) and got 30 plus failures concerned with wiFi.cpp - e.g. wifi_drv.h no such file or directory. No Serial Port error reported.

davidhux:
I have run Blink under OSX Arduino - on port tty.usbmodem*, (As reported by /dev/tty) and no problem.

It would appear that I need to have the Arduino plugged in when I use XCode (?)

As mentioned page 49 of the User Manual, each target has a specific agenda:

• All cleans the files from a previous compilation, compiles and links, uploads and opens a serial window in Terminal.

So you need the board to be plugged-in to upload.

• Build compiles all the files, changed and unchanged, and links them.

No plugged-in board is required.

davidhux:
I then returned to Xcode and set the Option to BUILD (as suggested) and got 30 plus failures concerned with wiFi.cpp - e.g. wifi_drv.h no such file or directory. No Serial Port error reported.

Please, you're going too fast...

If the blink example works on the Arduino IDE, have you tried it on Xcode before trying a more complex example?

You need to validate each step, with one single change per step.

About the WiFi, I guess some specific libraries need to be installed. Have you installed them? Does the sketch compile on the Arduino IDE? Have you check the sketchbook is correctly defined —page 9 sq., ibid.? Have you restricted some libraries for faster compilation —page 51, ibid.?

oops - I will slow down -

Blink runs in Arduino under OSX

Now I understand the Build Options - I get a clean build but when I try to UPLOAD the Blink app I get:

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -D -patmega328p -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -carduino -b115200 -P/dev/tty.usbmodem26421 -Uflash:w:Builds/embeddedcomputing.hex:i

Avrdude: can't open input file Builds/embeddedcomputing.hex: No such file or directory

Looks as though I have not done something!

My thanks and apologies for any confusion.

The target UPLOAD requires the file Builds/embeddedcomputing.hex to be ready.

Have you checked that the file Builds/embeddedcomputing.hex is available?

Use instead the target ALL = CLEAN + BUILD the sketch + ULPOAD to the board + SERIAL console.

It might be easier to use the contact form to send me the content of the Log Navigator.