Arduino on Xcode Project — Official Thread

Right - I knew that the Library directory was for the Arduino IDE, but the instructions in the guide regarding it confused me. It made me think that the Arduino IDE was going to also create and insert its default libraries there. And then by some quirk of the whole X Code template situation, I might need to add (but not copy) those libraries so that the compiler can find everything. In digging into the template though, I see that all default Arduino libs are actually included as part of the project.

Anyhow, my mistake. It seems this step is only relevant if one actually has additional libraries they want to include at the time of creating their project.

So just to make sure I understood everything so far, should the SKETCHBOOK_DIR be pointed at my ~/Documents/Arduino path (where the IDE identifies the Sketchbook and where Library will soon be) or the X Code project's Sketchbook directory?

Thanks again.

The SKETCHBOOK_DIR should be pointed at your ~/Documents/Arduino path to take into account your personal libraries.

Once again, Xcode is a professional IDE and, as so, requires some learning.

I strongly recommend the book Xcode 4 Unleashed by Fritz F. Anderson I've purchased thanks to contributions.

Please keep in mind the embedXcode User Guide is not an introduction to Xcode. It implies some fluency with Xcode.

Enjoy :wink:

Thanks.

At this point I can build the Build target, but code sense is still not working on PDE files despite having their type set to C++ Source and re-indexing 3 times now.

None of the other standard C/C++ file types are having this issue. It's as if the if-def header isn't being processed properly in specifically the PDE file despite it otherwise being treated like a C/C++ file.

EDIT - Per your suggestion, I eliminated the larger if-def block in place for just Android.h since that's the only platform I am working with. After re-indexing, everything seems to be fine.

Thank you so much for setting this whole thing up.

Normally, code-sense should work after the first build even for the pde or ino file.

Try closing the project and opening it again.

Xcode has sometimes strange behaviours.

Please find the new release of embedXcode

Oct 21, 2012 • Selection of pde, ino or cpp extension for the sketch

When creating a new project, select the extension on the drop-down list:
• Choose pde for Arduino 0023, chipKIT MPIDE, Wiring and Leaflabs Maple,
• Choose ino for Arduino 1.0 and Energia,
• Choose cpp optionally for a standard C++ file.

Using a pde or ino extension allows to edit the sketch with the standard IDEs of the boards.

Find documentation at http://embedxcode.weebly.com
and download from http://embedxcode.weebly.com/download.html

Enjoy :wink:

I'm implementing support for Due on embedXcode.

Building and linking work fine.

Unfortunately, I can't proceed with the uploading tests as I don't own an Arduino Due board.

Learn more :slight_smile:

Same here. The amazing invisible board :slight_smile:

I'm implementing support for Due on Xcode for Mac OS X with the template embedXcode.

Building and linking work fine.

Unfortunately, I can't proceed with the uploading tests as I don't own an Arduino Due board.

Can an Arduino Due owner post the verbose output for upload?

Thanks!

Dear avenue33 (or anybody else who may help),

I have installed embedXcode but get stuck since a couple of days when trying to execute the build target.
I get errors that suggest that the compiler would not accept overloading functions. (screenshot attached)
Also, the UDPbytewise library seems to request a "Types.h" include that cannot be found.
What kind of confuses me is also that those are "Shell Script Invocation Errors".
Any idea if this is a compiler flag not set or something of that sort? I really would like this to work, as I have a project that I need to separate into different libraries and classes to be maintainable, and the Arduino IDE is just not made for that.

Any help would be greatly appreciated.

Does the project compile with the standard Arduino IDE?

The "already defined here" message occurs when the same libraries are in two places:

  • first under the sketchbook / libraries folder
  • and second under the project folder.

The screenshot doesn't provide enough clues to help you more. What is the board used?

Thank you for your input.

I try to build for Arduino Mega 2560

On the standard IDE, I get the following error:

main.cpp:45:25: error: BlinkTest.ino: No such file or directory

If I remove main.cpp from the project, it compiles (this does not seem strange, as the main.cpp is probably already "hidden" in the Arduino IDE), but I get some warnings:
Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp:82: warning: comparison between signed and unsigned integer expressions
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp:390: warning: comparison between signed and unsigned integer expressions
and
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.cpp:44: warning: 'progmem' attribute ignored
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp:93: warning: only initialized variables can be placed into program memory area

Attached is the path of the project folder. The Sketchbook folder is empty, except for the .txt file, the others have all the .h and .cpp files in them.
Does that seem right?

Any clues?

Screen Shot 2012-11-05 at 18.24.57.png

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: