Arduino on Xcode Project — Official Thread

avenue33:
The light is green so compilation is successful.

I know, but EmbedXCode didn't do any of the stuff described in step 3.1.2. The automatic procedure is supposed to prepare the project by adding setting the file type for .ino files to C++, setting click to error , adding core libraries etc. It didn't do any of those things.

Ok. Create a new project and then go inside

folder_for_Xcode_projects/embed1/embed1/Utilities

and check if embedXcode_prepare is inside.

Once you have launched the first compilation, embedXcode_prepare is used and then deleted.

Capture d’écran 2013-04-08 à 18.25.59.png

avenue33:
Ok. Create a new project and then go inside

folder_for_Xcode_projects/embed1/embed1/Utilities

and check if embedXcode_prepare is inside.

Once you have launched the first compilation, embedXcode_prepare is used and then deleted.

I created Test8 and I do see embedXcode_prepare. It's also in my previous project (test7), but it's colored red, maybe that means it's deleted. Attached are screen shots for both.

For test8, could you please launch Build and send me the history log.

avenue33:
For test8, could you please launch Build and send me the history log.

see attached

embedxcode test8 log.txt (135 KB)

At last, after 5 days of research and endless posts, the key element is

/bin/sh: line 1: 38998 Segmentation fault: 11  Utilities/embedXcode_prepare /Users/Scott/Documents/Arduino_OLD/Test8/Test8.xcodeproj

I guess this was caused by embedXcode_prepare running on OS X 10.7.

Now, I've compiled embedXcode_prepare specifically for OS X 10.7 and released a new version of embedXcode

embedXcode • Apr 08, 2013 release 38 • embedXcode_prepare for OS X 10.7

I tested it successfully on my OS X 10.8 Mac.

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

Enjoy :slight_smile:

avenue33:
At last, after 5 days of research and endless posts, the key element is

/bin/sh: line 1: 38998 Segmentation fault: 11  Utilities/embedXcode_prepare /Users/Scott/Documents/Arduino_OLD/Test8/Test8.xcodeproj

I guess this was caused by embedXcode_prepare running on OS X 10.7.

Now, I've compiled embedXcode_prepare specifically for OS X 10.7 and released a new version of embedXcode

embedXcode • Apr 08, 2013 release 38 • embedXcode_prepare for OS X 10.7

I tested it successfully on my OS X 10.8 Mac.

It's working now, thanks for the update!! Now I can get back to my original problem where the build is failing when I have user libraries installed. I'm hoping #include "Arduino.h" fixes that issue.

Now that Xcode compiles without errors I've started adding my user libraries back to my \library folder. Most of the libraries compile fine, but not all. The first one I'm trying to tackle is DallasTemperature.h. Arduino.h is already included, so that shouldn't be the problem. The library works fine in Arduino IDE 1.0.4, I compiled a couple of the example sketches without errors in the Arduino IDE.

Attached are some of the errors and the library file.

DallasTemperature_372Beta.zip (22.9 KB)

ScottG:
Now that Xcode compiles without errors I've started adding my user libraries back to my \library folder. Most of the libraries compile fine, but not all. The first one I'm trying to tackle is DallasTemperature.h. Arduino.h is already included, so that shouldn't be the problem. The library works fine in Arduino IDE 1.0.4, I compiled a couple of the example sketches without errors in the Arduino IDE.

Until I can figure out why the DallasTemperature library won't compile on xcode I'm trying to exclude it, I added it the the makefile:
EXCLUDE_LIBS = Firmata WiFi Esplora OneWire DallasTemperature

But that didn't help, xcode still gives me the same errors when I run Build.

I'm trying to follow step 3.2.2 (Declare Sources for Code Sense) in the manual, but the screenshots are really blurry and I can't figure out what to do. I attached a screen shot of what I think is the target index and build phases pane. But I don't see an add items button There is an add Target, but that doesn't seem to be the same. I Googled around for help, but didn't find anything.

Screen Shot 2013-04-09 at 9.18.57 PM.png

avenue33:
I strongly recommend you to refer to the book Xcode 4 Unleashed by Fritz F. Anderson

I just got the Kindle version.

ScottG:
Now that Xcode compiles without errors I've started adding my user libraries back to my \library folder. Most of the libraries compile fine, but not all. The first one I'm trying to tackle is DallasTemperature.h. Arduino.h is already included, so that shouldn't be the problem. The library works fine in Arduino IDE 1.0.4, I compiled a couple of the example sketches without errors in the Arduino IDE.

I figured out how to solve this compile problem. In Makefile I changed

EXCLUDE_LIBS = Firmata WiFi Esplora OneWire

to

EXCLUDE_LIBS = Firmata WiFi Esplora

ScottG:
I'm trying to follow step 3.2.2 (Declare Sources for Code Sense) in the manual, but the screenshots are really blurry and I can't figure out what to do. I attached a screen shot of what I think is the target index and build phases pane. But I don't see an add items button There is an add Target, but that doesn't seem to be the same. I Googled around for help, but didn't find anything.

I figured it out. I don't know why I didn't see the + at the bottom of the list the first time.

Code-Sense isn't working for basic Arduino keywords like pinMode() and delay() . I re-indexed as described in step 4.6, but still no luck.

I'm using version the latest version of embedXcode.

Each release of Xcode changes the way code-sense works.

I suggest to get rid of the whole core library for code-sense block and keep only

#include "Arduino.h"

Also, launch one compilation.

avenue33:
Each release of Xcode changes the way code-sense works.

I suggest to get rid of the whole core library for code-sense block and keep only

#include "Arduino.h"

Also, launch one compilation.

No luck, here's what I did.

  • Changed INO file so only had #include "Arduino.h" in the Code-Sense block
  • Saved and closed the project
  • Went to organizer folder and deleted Derived Data
  • Opened my project
  • The project re-indexed itself
  • Ran Build

Attached is a screenshot of what the code looks like after doing this.

Edit: The auto-complete does seem to work, it's just the colors don't match what I see in your manual.

Screen Shot 2013-04-17 at 8.34.59 AM.png

The procedure you've followed is basically this described on section 4.6 Re-Index the Keywords for Code-Sense.

Strange enough, code-sense, auto-completion and arguments list are displayed usually without problem in my laptop. Now, it isn't a 100% hit and Xcode dedicated forums recommend the procedure you've followed and I've mentioned in the user manual.

Unfortunately, as code-sense implementation changes with every Xcode release and as Apple is more than secretive about the customisation of Xcode, I'm sorry I can't be of much help.

avenue33:
The procedure you've followed is basically this described on section 4.6 Re-Index the Keywords for Code-Sense.

Strange enough, code-sense, auto-completion and arguments list are displayed usually without problem in my laptop. Now, it isn't a 100% hit and Xcode dedicated forums recommend the procedure you've followed and I've
mentioned in the user manual.

Unfortunately, as code-sense implementation changes with every Xcode release and as Apple is more than secretive about the customisation of Xcode, I'm sorry I can't be of much help.

I think code-sense is working but the colors are different from your manual. Or maybe it's partially working.
Can you give me links to the xcode forums you like to go to?

I have another smaller issue, not a show stopper. When I create a new project, xcode does no do a reindex on it's own. But when I go do my first build and where embedxcode does it's thing, the Build is cancelled because the index starts. I did notice the the embedxcode changes all seem to be there, so that's good. Once the indexing is done, if I start another Build, it finishes okay. Is there a way for me to make xcode do the index so it doesn't just start it on it's own and cancel my first Build. I guess I could follow the code-sense same re-indexing procedure, but I'm wondering if there is something more direct. I tried Run > Index, but that didn't work, I guess that's for something else.

ScottG:
I think code-sense is working but the colors are different from your manual. Or maybe it's partially working.

Yes, the colours may vary, due to different available configurations —see attached screen-shot— and due to different interpretation of the functions as Project Class Names or Other Class Names, Project Function and Method Names or Other Function and Method Names.

ScottG:
Can you give me links to the xcode forums you like to go to?

Sure, Newest 'xcode' Questions - Stack Overflow and http://apple.stackexchange.com

ScottG:
I have another smaller issue, not a show stopper. When I create a new project, xcode does no do a reindex on it's own. But when I go do my first build and where embedxcode does it's thing, the Build is cancelled because the index starts. I did notice the the embedxcode changes all seem to be there, so that's good. Once the indexing is done, if I start another Build, it finishes okay. Is there a way for me to make xcode do the index so it doesn't just start it on it's own and cancel my first Build. I guess I could follow the code-sense same re-indexing procedure, but I'm wondering if there is something more direct.

On embedXcode releases up to 40, the preparation of the project is done the first time compilation is asked for, but actually before the compilation really starts. As Xcode tries to do two thinks at the same time, it realises the project has been changed by the preparation and thus stops the compilation.

On embedXcode releases 41 and on, the preparation of the project is still done the first time compilation is asked for, but this time after compilation is completed, avoiding conflicts of multi-tasking.

The preparation provides Xcode with all the references required for building the index, so code-sense, auto-completion and argument list can work.

ScottG:
I tried Run > Index, but that didn't work, I guess that's for something else.

As explained in section 5. Build and Upload the Project — 5.1. Select a Target,

Index is a proxy target solely used for code-sense. Do not launch it.