Pages: 1 [2] 3 4 ... 46   Go Down
Author Topic: Arduino on Xcode Project — Official Thread  (Read 145301 times)
0 Members and 3 Guests are viewing this topic.
France
Offline Offline
God Member
*****
Karma: 11
Posts: 644
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with this approach: all the parameters are on the files

/Applications/Mpide.app/Contents/Resources/Java/hardware/arduino/platforms.txt
/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/platforms.txt

The Arduino IDE or the chipKIT MPIDE are great tools. However, they are closed.

Both Arduino and chipKIT should disclose more so any standard IDE could be used: Visual Studio, Eclipse, Xcode, to name a few.
Logged


SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6784
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Arduino IDE or the chipKIT MPIDE are great tools. However, they are closed.
They're not "closed."  They are just rather tightly controlled.  You can download the sources and make the patches to do what I described, but the chance that the patches will be accepted for inclusion in future releases is quite small.
Logged

Antwerp, Belgium
Offline Offline
Jr. Member
**
Karma: 2
Posts: 64
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What we "need" is a command-line mode of the Arduino app that does the Arduino-style preprocessing on a set of .pde (or .ino) files.
Having to figure out exactly what it does (slightly differently) with each Arduino release is a pain, and makes implementing Arduino program builds in other IDEs an exercise in chasing not-fully-documented behaviors. :-(

What do you mean with "preprocessing" exactly? In the XCode version, we are just using the Arduino C and Cpp libraries and avr-gcc to compile for the arduino, but no special preprocessing.

Or do you mean the converting from .pde files into .h and .cpp files that probably happens behind the screens in the Arduino IDE?

best,
tim.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6784
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you mean the converting from .pde files into .h and .cpp files
Yep; that.  Concatenate the .pde files, generate function prototypes, add the default .h files, and detect the used libraries.  More or less.  Subject to change.
Logged

Antwerp, Belgium
Offline Offline
Jr. Member
**
Karma: 2
Posts: 64
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you mean the converting from .pde files into .h and .cpp files
Yep; that.  Concatenate the .pde files, generate function prototypes, add the default .h files, and detect the used libraries.  More or less.  Subject to change.

hmmm I'm not sure about that... I have absolutely no problem with writing good code when I get all the advantages in XCode.
Also, the code completion probably wouldn't work if you start working with .pde files without proper header files, right?

I think it would make more sense to have two types of working: the easy to learn and quick-sketch Arduino IDE way and a way for more experienced programmers to work with their preferred IDE and a good makefile.

best,
tim.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6784
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sure, as long as you don't end up creating sketches that can ONLY be compiled from the XCode environment.  Assuming that you want to share your code, it'll need to compile from the Arduino IDE as well.  I don't think that this has been a problem so far, but I can see it becoming one as programs get larger.
Logged

Antwerp, Belgium
Offline Offline
Jr. Member
**
Karma: 2
Posts: 64
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hey Westfw,

I think this won't be such a big problem. The things people share are more like snippets of code to do something specific and explain a concept or libraries, and they of course would work in any environment as they seem to be always made up of proper .h, .cpp and .c files.

When working in XCode, there is no reason to stick to the Arduino convention of naming the main .pde file the same as the project folder, so when going from XCode to Arduino IDE you'll need to re-name that main file.

That is the only compatibility problem in the XCode -> Arduino IDE direction that I can think of.. The other direction could be a bit more involved because of the preprocessing, but still not a big deal.

I can't really imagine anything that would be workable in XCode (it's still the same compiler..) and would not work in the Arduino IDE.

best,
tim.
« Last Edit: November 14, 2011, 09:04:51 pm by timKnapen » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6784
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
always made up of proper .h, .cpp and .c files.
   :
I can't really imagine anything that would be workable in XCode and would not work in the Arduino IDE.

Well, you could send out a supposedly complete project with no .pde file, for example.
Logged

France
Offline Offline
God Member
*****
Karma: 11
Posts: 644
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Westfw

Feel free to join the project.

As the thread title stands, we plan to deal with Xcode.

Presently, the linker problem is solved and Xcode can compile sketches with #include libraries.

Now, next step is a template.
Logged


France
Offline Offline
God Member
*****
Karma: 11
Posts: 644
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Tim,

Avenue33, did you try my project template with XCode 4? I think you can just open it as a normal project with XCode4.
I don't have a computer that runs Lion yet, so I can't test this.

The templates on Xcode 4 are totally different from and incompatible with those on Xcode 3.

Building fails with the following error message:

Code:
    make

pic32-g++    -Wl,--gc-sections -mprocessor=32MX795F512L -Xlinker -T/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/cores/pic32/chipKIT-MAX32-application-32MX795F512L.ld -Xlinker -o/Users/avenue33/Desktop/Xcode_chipKIT/main.elf -Xlinker -M -Xlinker -Map=/Users/avenue33/Desktop/Xcode_chipKIT/main.map
/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/compiler/pic32-toavenue33/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/lib/cpp-startup.o: In function `_main_entry':
(.text+0x10): undefined reference to `main'
collect2: ld returned 1 exit status
make[1]: *** [/Users/avenue33/Desktop/Xcode_chipKIT/main.elf] Error 1
make: *** [build] Error 2
Command make failed with exit code 2


On top of that, Xcode doesn't recognise the symbols and doesn't jump to the definition.

Enclosed the culprit.

My template for chipKIT is broken and I don't know why smiley-sad

I hope you'll be luckier than me smiley-wink

* 2011-11-15 Makefile Arduino.txt (3.07 KB - downloaded 49 times.)
Logged


Antwerp, Belgium
Offline Offline
Jr. Member
**
Karma: 2
Posts: 64
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, you could send out a supposedly complete project with no .pde file, for example.

right, similar to this:
Quote
When working in XCode, there is no reason to stick to the Arduino convention of naming the main .pde file the same as the project folder, so when going from XCode to Arduino IDE you'll need to re-name that main file.

the "no .pde" problem is as easily solved by renaming your main file. The Arduino IDE has no problem with having other .h and .cpp files in your project as far as I know.
And the syntax doesn't change so even if you share a project that has no .pde file in it, people can just as easily understand what you are doing.
I think you're right, whatever you do, there will be a tiny little compatibility problem but it it's still all C++ code...

On the other hand what is the benefit of working with pde files in XCode?

best,
tim.
« Last Edit: November 15, 2011, 07:49:01 am by timKnapen » Logged

Antwerp, Belgium
Offline Offline
Jr. Member
**
Karma: 2
Posts: 64
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Tim,
The templates on Xcode 4 are totally different from and incompatible with those on Xcode 3.

Yes, I know the templates are completely different now, I will try to look into that over the weekend when I might be able to steal my sister's macbook running Lion... :-)
But I thought the XCode projects were still compatible... no?


Building fails with the following error message:
Code:
    make
pic32-g++    -Wl,--gc-sections -mprocessor=32MX795F512L -Xlinker -T/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/cores/pic32/chipKIT-MAX32-application-32MX795F512L.ld -Xlinker -o/Users/avenue33/Desktop/Xcode_chipKIT/main.elf -Xlinker -M -Xlinker -Map=/Users/avenue33/Desktop/Xcode_chipKIT/main.map
/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/compiler/pic32-toavenue33/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/lib/cpp-startup.o: In function `_main_entry':
(.text+0x10): undefined reference to `main'
collect2: ld returned 1 exit status
make[1]: *** [/Users/avenue33/Desktop/Xcode_chipKIT/main.elf] Error 1
make: *** [build] Error 2
Command make failed with exit code 2

Wait, that is a completely different log, that can't be from the makefile in my XCode example

On top of that, Xcode doesn't recognise the symbols and doesn't jump to the definition.
I've had the same problem in XCode 3.2 The solution was to go to Project>Edit Project Settings>General and set "Project Format" to XCode3.2 compatible. Maybe try to set yours to XCode4 if this option still exists?

Otherwise, try rebuilding your codesense index... ?

Enclosed the culprit.

My template for chipKIT is broken and I don't know why smiley-sad

I hope you'll be luckier than me smiley-wink

I think I will download your complete project from github and try it this weekend, maybe new eyes see something new :-)

best,
tim.
Logged

France
Offline Offline
God Member
*****
Karma: 11
Posts: 644
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour Tim,

Sorry, I missed the most important:

#include libraries are compiled on Arduino UNO!

Thank you so much for your help smiley .

I pushed a commit to your repository suggesting taking avr/bin from within Arduino.app.

But for chipKIT, the Makefile no longer works.

I try to deal with both platforms.

Is there an Xcode 4 expert around?
Logged


Antwerp, Belgium
Offline Offline
Jr. Member
**
Karma: 2
Posts: 64
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour Tim,

Sorry, I missed the most important:

#include libraries are compiled on Arduino UNO!

Thank you so much for your help smiley .

I pushed a commit to your repository suggesting taking avr/bin from within Arduino.app.

But for chipKIT, the Makefile no longer works.

I try to deal with both platforms.

Is there an Xcode 4 expert around?

Hey great! so it is working now? With codesense etc?

I noticed your commit to github with the comment about using the avr-gcc from Arduino.app. I'm very new to GIT and github, so I had no clue how to import your adjustments... so I simply edited it in the makefile I was working on.
It was anyway already a completely different version than the one you branched from.
I just had one weird error with the inclusion of avrdude.conf but that was fixed easily and now it is working the way you suggested.

I'm going to try to become an XCode4 expert over the weekend.

ahoy!
tim.
Logged

France
Offline Offline
God Member
*****
Karma: 11
Posts: 644
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

References about Makefile

Short http://makepp.sourceforge.net/1.19/makepp_tutorial.html
Long http://www.gnu.org/software/make/manual/html_node/index.html
Logged


Pages: 1 [2] 3 4 ... 46   Go Up
Jump to: