Arduino on Xcode Project — Official Thread

I am a new EmbedXcode user (and a novice Arduino user, to boot). I am trying to develop on the ESP-32 TTGO LORA-OLED board. I got some test code working under the Arduino IDE, but when I try to get it to compile under Xcode, it can't find some header files that are referenced from other header files.

I am using BLE, and I have included the BLE library here in the make file:

APP_LIBS_LIST = Wire BLE

But, some of the headers in BLE refer to files in a different location. For example, bleaddress.h references esp_gap_ble_api.h, which is located here:
~/Documents/Arduino/hardware/espressif/esp32/tools/sdk/include/bluedroid/api/esp_gap_ble_api.h

bluedroid is not a "library", so adding it to the makefile doesn't help. Also, explicitly adding the full path to the file doesn't work, either.

How do I tell Xcode (via EmbedXcode) to search this path:
~/Documents/Arduino/hardware/espressif/esp32/tools/sdk/include/bluedroid/api

??

I created a ticket, and support responded with an updated make file that fixes the issue.

Now I am having a different problem. When I try to compile the code, I get the following error:

throw new BLEUuidNotFoundException; error: exception handling disabled, use -fexceptions to enable

I searched for this error and found a thread that says to change -fno-exceptions to -fexceptions in platform.txt, but doing this had no effect (do I need to start from scratch on a new project?).

  • To report an issue, open a ticket at the Help Desk.

Please find a new major release of embedXcode.

  • embedXcode • 25 Sep 2018 release 10.0.6 • Added IDE path to board configuration files
  • embedXcode+ • 25 Sep 2018 release 10.0.6 • Added IDE path to board configuration files

embedXcode now supports Xcode 10 on macOS 10.14 Mojave.

Download

Release 10.2.3 updates support for Xcode 10.1 and macOS 10.14.1.

Download

How do I get the serial terminal to output a CR LF on return when entering from the keyboard.

You have different options:

  • set parameters for the screenutility,
  • use another serial console utility

Please refer to Manage the serial console after upload for more information.

I just downloaded embedxcode, and I am having trouble getting it to work. I have the Arduino 1.8.9 release with all the board files updated to the latest available version. I start a new embedxcode project in Xcode, don't even add any code, and I can compile it, but if I try to upload it I get "avrdude: ser_open(): can't open device "/dev/tty.usbmodem14201": No such file or directory". This is the port that is configured for my Leonardo in the Arduino IDE, and compiling and uploading sketches from there works fine. Any ideas on how to fix this issue?

I'm using Mac 10.14.5, Xcode 10.2.1.

Please open a ticket at the Help Desk with What information to provide when asking for help. Thank you!

If the issue is about the Arduino Leonardo board, version 10.9.8 released 08 Jul 2019 improved stability for the Arduino Leonardo board.

Hello,

Are there any plans to incorporate the Arduino CLI into embedXcode so the IDE is not required?

Thank you,

Release 11.2.1 of embedXcode adds support for Xcode 11.1 on macOS 10.15 Catalina.

It also brings support for latest Arduino Nano boards.

Download

sslupsky:
Hello,

Are there any plans to incorporate the Arduino CLI into embedXcode so the IDE is not required?

Thank you,

Actually, embedXcode doesn't require any component of the Arduino IDE except for managing and updating the boards packages. embedXcode relies on its own build manager for speed and customisation.

I've been using Visual Studio Code for a while now with Arduino and have become somewhat familiar with that workflow and quite prefer it to using the Arduino IDE.

I am not sure if you are familiar with vs code but I thought to ask you if you can comment on how the embedXCode environment compares to vs code? I am a macOS guy so I think I might like the embedXCode environment better because my general experience is UI issues are thought out much better in macOS. However, I do not have any actual experience using Xcode so wondering if there are limitations using Xcode compared to vs code for Arduino.

FWIW, I use the following extensions with vs code:

Arduino
Bookmarks
C/C++
Debugger for Chrome
Docker
Doxygen documentation
Git Graph
GitLens
npm
Python
SPICE

Thank you for your interest in embedXcode. I tested Visual Studio Code with the dedicated Arduino extension but wasn't happy with the splash screens.

The first main difference relies on the underlying IDE: Xcode versus Visual Studio Code. So it is more about which IDE are you more familiar with. Xcode is a very polished IDE with code-sense, check-as-you-type, and the features listed at A Glimpse of Xcode.

The second main difference is that embedXcode uses GNU make as build manager and not the Arduino Builder (with the splash screens).

The best way is to see by yourself and give a try with the embedXcode standard edition.

Yeah, the Arduino plugin for vscode is pretty weird. Moreover, it doesn't work well with IntelliSense so the code checking can be problematic. I've pretty much figured out what you need to do to get IntelliSense to work properly. Unfortunately, someone responsible for the plugin broke it a few months ago by adding a "feature" that "auto" includes some recursive include paths. Unfortunately, you cannot turn this "feature" off so it is a headache because if often uses the wrong header. Thus, my interest in using Xcode instead.

Does Xcode support linting using the a third party gnu compiler? I could not find a setting anywhere that let me specify the compiler. This is one of the things you need to do with vscode to set it up properly. I've got my linting set up to point to the same gcc compiler that Arduino uses.

Recently, I started using the arduino-cli and vscode "tasks" to do the build instead of using the plugin.

I recall I downloaded the standard edition a while ago. I'll give it a go and see what happens. Thanks for the feedback.

Hi,

I just installed embedXCode and have it successfully uploading my Star Wars Astromech control program to an Arduino Mega 2560. I have several libraries to run servos and LEDs in real time. The code sense works fine for all of these libraries. However, I cannot get the basic Arduino commands to use code sense (such as Serial.println("Gripper Arm DeActivated");).

Additionally, it doesn't seem to recognize procedures if they are defined after the procedure that calls them. I was able to reorder the code to get the sketch to compile. However, this isn't normal behavior. I should be able to declare a function at the end of the file that gets called from the main loop without getting a build error.

For example, using the Arduino IDE this code works and compiles just fine. But in embedXCode I get a "swapPS3NavControllers was not declared in this scope" error.

void onInitPS3(){
Serial.print(F("\r\nGot to onInitPS3"));
String btAddress = getLastConnectedBtMAC();
PS3Nav->setLedOn(LED1);
isPS3NavigatonInitialized = true;
badPS3Data = 0;
//sfx.playTrack("T12 OGG");
trigger.trigger(23);
#ifdef SHADOW_DEBUG
output += "\r\nBT Address of Last connected Device when Primary PS3 Connected: ";
output += btAddress;
if (btAddress == PS3MoveNavigatonPrimaryMAC){
output += "\r\nWe have our primary controller connected.\r\n";

}else{
output += "\r\nWe have a controller connected, but it is not designated as "primary".\r\n";
}
#endif
}

void onInitPS3Nav2(){
String btAddress = getLastConnectedBtMAC();
PS3Nav2->setLedOn(LED1);
isSecondaryPS3NavigatonInitialized = true;
badPS3Data = 0;
//sfx.playTrack("T12 OGG");

//TODO:Fix the error when uncommenting line below
if (btAddress == PS3MoveNavigatonPrimaryMAC) swapPS3NavControllers();///<-------Error on this line !!
#ifdef SHADOW_DEBUG
output += "\r\nBT Address of Last connected Device when Secondary PS3 Connected: ";
output += btAddress;
if (btAddress == PS3MoveNavigatonPrimaryMAC){
output += "\r\nWe have our primary controller connecting out of order. Swapping locations\r\n";
}else{
output += "\r\nWe have a secondary controller connected.\r\n";
}
#endif
}

void swapPS3NavControllers(){
PS3BT* temp = PS3Nav;
PS3Nav = PS3Nav2;
PS3Nav2 = temp;
//Correct the status for Initialization
boolean tempStatus = isPS3NavigatonInitialized;
isPS3NavigatonInitialized = isSecondaryPS3NavigatonInitialized;
isSecondaryPS3NavigatonInitialized = tempStatus;
//Must relink the correct onInit calls
PS3Nav->attachOnInit(onInitPS3);
PS3Nav2->attachOnInit(onInitPS3Nav2);
}

I have gone through all of the help files from the embedXCode website about reindexing and manual setup and updating the makefile. I don't know if it matters, but all of the example screen shots show the Arduino icon on the project .ino file while my .ino file has a C++ icon.

Any help would be greatly appreciated. I have spent five days mucking around with this and can't seem to make it work as expected.

You need to forward declare the function to clear up the error.

For instance, at the top of the file include the following forward declaration (prototype):

void swapPS3NavControllers(void);

That fixed the build error. Thanks. Is this normal behavior in embedXCode?

Thanks,

Tim

Yes, as I understand embedXCode, it performs a "make" style build which follows all the standard C and C++ conventions. The declaration before use is required for C and C++. The forward declaration satisfies this by providing the information the compiler requires to understand the function call properly.

The Arduino IDE gets around this by scanning the sketch and deriving a set of prototypes and then it inserts them into the code before it is compiled.