Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interoperability between vscode-swift and vscode-cpptools/vscode-cmake-tools #586

Open
H-G-Hristov opened this issue Aug 21, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@H-G-Hristov
Copy link

How-To achieve: Interoperability between vscode-swift and vscode-cpptools/vscode-cmake-tools

https://github.com/Microsoft/vscode-cpptools
https://github.com/microsoft/vscode-cmake-tools

I have somewhat interesting project setup: It is a CMake based project, with CMakeLists.txt in the main project directory. In subfolders there are Swift projects. The old one is a Xcode project. And now I want to add a new one SPM based project and to be able to use VSCode and the Swift extension to build, debugging and run it.

Normally I open the main project directory in VSCode. The SPM is executed on the Swift project but it doesn't seem that I am able to build and run the Swift project like that.

When I build my project all of the components C++ and Swift should be packaged into a single installer file and deployed like that.

So would it be possible to have a multi folder project support?

@H-G-Hristov H-G-Hristov added the enhancement New feature or request label Aug 21, 2023
@adam-fowler
Copy link
Contributor

adam-fowler commented Aug 21, 2023

The extension does have multiple project support but you have hit the one case where it doesn't work in a slightly around about way.

The extension supports multiple projects as long as they aren't inside each other. Because the extension also supports CMake projects it considers your SwiftPM project to be inside the CMake project and doesn't treat it as a separate project.

@H-G-Hristov
Copy link
Author

Thank you for explaining. What would be your recommendation how to handle my unfortunate situation? Maybe I should just open the Swift project in its subfolder

Would it be possible for the extension to handle the different project layouts?

Just to repeat myself. For historical reasons I cannot change the layout of the project. As stated above my current layout:

/ProjectFolder
 |- CMakeLists.txt
 |- Sources (C++)
 |
 |- FirstSwiftProjectFolder (independent project)
 |    |- Package.swift
 |    |- Sources
 |    |
 |
 |- SecondSwiftProjectFolder (independent project)
 |    |- Package.swift
 |    |- Sources
 |    |

Another type of layout is:

/ProjectFolder
 |- CMakeLists.txt
 |- Sources (C++)
 |
 |- FirstSwiftProjectFolder (dependent project - library)
 |    |- Package.swift
 |    |- Sources
 |    |
 |
 |- SecondSwiftProjectFolder (independent project)
 |    |- Package.swift
 |    |- Sources
 |    |

Perhaps the proper layout should be:

Another type of layout is:

/ProjectFolder
 | -CPPProject
 |   |- CMakeLists.txt
 |   |- Sources (C++)
 |   |
 |   |- FirstSwiftProjectFolder (dependent project - library)
 |      |- Package.swift
 |      |- Sources
 |      |
 |
 |- SecondSwiftProjectFolder (independent project)
 |    |- Package.swift
 |    |- Sources
 |    |

With the coming C++/Swift interoperability it will make sense to use Swift over Objective-C for implementing libraries/modules.

@adam-fowler
Copy link
Contributor

In your final layout the SecondSwiftProjectFolder would load as it is not inside the folder that holds the CMakeLists.txt.

One other thing to consider is sub-folder projects only open when you open a swift file from that project. I implemented it that way as I thought opening everything at startup might be desired. I'm planning to add an option to open everything automatically. At the same time I could look at projects inside projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants