markohlebar / Peckham

Add #import-s from anywhere in the code.
MIT License
714 stars 94 forks source link

C++ Support #85

Closed FramusRock closed 8 years ago

FramusRock commented 8 years ago

Just a short question:

Is it planned to also support C++?

To achieve this basically instead of "import", you have to do "include".

A setting for this would be sufficient. Or is there one and I missed it?

clementpadovani commented 8 years ago

Hey @FramusRock, we’re talking about just C++ support and not Objective-C++?

And if I recall, C++ header files have a hpp extension right?

I guess this could be easily integrated without having any settings.

FramusRock commented 8 years ago

Hey @ClementPadovani, thanks for the fast response! :)

Yes, we're talking about pure C++. Xcode is not often used for that - though it's (kind of) the only possibility to run C++ code on iOS, that's why I need it. And of course also because I love Xcode ;)

Not all C++ headers have a hpp extension. It's a matter of personal style. I'm using a library which mainly uses h-files, so I also did this for my own files, to have most of the codebase with the same extensions.

As an "easy rule", you could use: Is the first import in the current file #include? --> Make all others #include, else use #import (or something similar).

I once tried to do that for the Auto-Importer Plugin, and it also kind of worked - though it didn't properly see all the C++ headers and I don't know why. It showed like 50% of the headers in the popup and the other 50% of possible headers never showed up, which makes it kind of useless.

clementpadovani commented 8 years ago

Hey @FramusRock,

Alright, I'll see what I can do. I currently have some free time. Feel free to check out the progress and jump in this branch: https://github.com/ClementPadovani/Peckham/tree/feature/cppSupport

Thanks, Clément Sent from my iPhone

On Apr 9, 2016, at 7:09 PM, FramusRock <notifications@github.com mailto:notifications@github.com> wrote:

Hey @ClementPadovani https://github.com/ClementPadovani, thanks for the fast response! :)

Yes, we're talking about pure C++. Xcode is not often used for that - though it's (kind of) the only possibility to run C++ code on iOS, that's why I need it. And of course also because I love Xcode ;)

Not all C++ headers have a hpp extension. It's a matter of personal style. I'm using a library which mainly uses h-files, so I also did this for my own files, to have most of the codebase with the same extensions.

As an "easy rule", you could use: Is the first import in the current file #include? --> Make all others #include, else use #import (or something similar).

I once tried to do that for the Auto-Importer https://github.com/citrusbyte/Auto-Importer-for-Xcode Plugin, and it also kind of worked - though it didn't properly see all the C++ headers and I don't know why. It showed like 50% of the headers in the popup and the other 50% of possible headers never showed up, which makes it kind of useless.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/markohlebar/Peckham/issues/85#issuecomment-207818553

markohlebar commented 8 years ago

Hey @FramusRock thanks for opening this issue. @ClementPadovani there is also different styles of naming headers, like .h++, .hpp, .hh etc... Can the language somehow be inferred from the project settings instead?

clementpadovani commented 8 years ago

Alright,

I’m not sure if Xcode can link an implementation file from a header will have to check it out with Xcode Editor.

FramusRock commented 8 years ago

Thank you @ClementPadovani and @markohlebar, for looking into it!

I just checked out my project and on the right side navigator in Xcode it says "C++ Source" for the cpp files and "C header" for the .h files. So if we're currently in a file tagged as "C++ Source", we can for sure use #include instead of #import. If it's C++ and #import was needed, the file would be tagged as "Objective C++ Source". If we're in a header, things get more difficult. If there's a corresponding cpp-file which is tagged as "C++ Source" this can be used, but for standalone headers we might have to fallback to the "Which import-style is already used in this file"-method.

FramusRock commented 8 years ago

On another note: I just found out that Peckham doesn't work at all from cpp files. The popup opens, but it does not import any headers if I press enter. It works fine in .h, .m and .mm files.

markohlebar commented 8 years ago

@FramusRock that sounds promising. I think the approach of cross checking if there is an associated "C++ Source" with the header is the way to go about this... I would say implement that first, and worry about headers that don't have an associated source file as a second step.

@ClementPadovani what do you think?

clementpadovani commented 8 years ago

Hey,

@markohlebar sounds good, I won't have any free time to work on this until this weekend however

Thanks, Clément Sent from my iPhone

On Apr 11, 2016, at 8:18 PM, Marko Hlebar notifications@github.com wrote:

@FramusRock that sounds promising. I think the approach of cross checking if there is an associated "C++ Source" with the header is the way to go about this... I would say implement that first, and worry about headers that don't have an associated source file as a second step.

@ClementPadovani what do you think?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

FramusRock commented 8 years ago

Hey, I just wanted to check back if you had time to get it to work yet.

clementpadovani commented 8 years ago

@FramusRock Hey, I’m currently really busy and I don’t really have much free time in the foreseeable future 😒

markohlebar commented 8 years ago

@FramusRock you can try using Import which supports C++. We will not be adding any features to Peckham since plugins ecosystem is waning.