Xcode project to Visual Studio - visual-studio

I do most of my home development in Xcode, however my classes require me to use Visual Studio 2010. I am curious if there is some tool that can convert my Xcode project to Visual Studio projects and back and structure the files the way the ides want them to be?
The programs I am writing are OS independent.

You might want to consider using a meta-make such as CMake that can generate both Visual Studio and Xcode project files.
It's probably not as ideal for you since you'll need to write the CMake file and then fix up both the Xcode and Visual Studio projects to your liking (though I believe CMake has some support for project organisation in Visual Studio—not sure about Xcode) rather than doing a straight conversion, but it would allow you to work in Xcode and submit as a Visual Studio project.

Related

Generate visual studio solution on mac with cmake

Using the CMake GUI, for the same CMakeList, I am able to generate VS solution files on Windows and XCode solution files on Mac. However I am unable to generate VS solution on Mac, as I don't use any VS options under Specify the generator for this project.
I have VS 2017 Community for Mac installed on the Macbook. Is there anything I am missing?
Visual Studio for Mac is very different from Visual Studio.
The former is based on Xamarin Studio, a product of Xamarin Inc., which was acquired by Microsoft in early 2016. Microsoft then basically rebranded Xamarin Studio as Visual Studio for Mac. Note that Xamarin Studio was mainly an IDE for developing mobile apps. Visual Studio for Mac currently has no support for C++.
Because of this, CMake currently does not support Visual Studio for Mac. The Visual Studio generators that ship with CMake only work with the Windows versions of Visual Studio.
And before someone asks: They also don't work with Visual Studio Code, which is yet another product that has little in common with Visual Studio except the name. Unlike Visual Studio for Mac however, Visual Studio Code has extensive support for C++ development with CMake through plugins and might be a viable alternative if you're looking for a Visual Studio-like development experience for C++ on Mac.
In that case, you open the workspace directly with VS Code and let its CMake plugins handle the configuration of CMake. You will not use the Visual Studio generators of CMake for VS Code, as VS Code is unable to work with the generated solution files.

CMake and editing code

I have seen many open-source projects use CMake as their build system. I'd like to use it too, but so far all of my development has been on Visual Studio (2015). This makes me wonder how I'm supposed to edit code when using CMake as a build system? Should I use editors like Vim or emacs, or can I still use Visual Studio (with IntelliSense, if possible)?
You can use CMake to generate Visual Studio solution for you:
https://cognitivewaves.wordpress.com/cmake-and-visual-studio/
But unfortunately the opposite is not possible(or harder than expected), for every new file or include folder generation you will have to update your CMakeLists.txt file respectively(edits do not require updating CMake), looking at the Visual Studio flags while compiling could help this, but the process is still manual:
Using CMake to generate Visual Studio C++ project files
cmake creating visual studio solution on the command line
There are also 3rd Party tools which could facilitate the production cycle for you, including the visual studio to CMake generation, but they are not officially supported

Can I use qt5 in visual studio without the add-in?

I understand I can use Qt5 in Visual Studio by using the Visual Studio Add-in for Qt as mentioned in Building Qt5 with Visual Studio 2012 / Visual Studio 2013, and integrating with the IDE.
Is it possible to use Qt5 in Visual Studio without using the Add-in?
Also, I would like to use CMake to generate the Visual Studio Project.
Yup.
I have it working for a pretty complex subdirs template.
Qmake can generate the visual studio solution file and vcxproj, look here:
http://doc.qt.io/qt-5/qmake-platform-notes.html#creating-visual-studio-project-files
What I do is use the Qmake project as the master project, and generate the VS stuff out of folder as temporaries. This prevents Visual studio from tangling up in your source files as well as in the qmake stuff. And you can also port it to other OSs without any hassle. Using this approach, if you want to add files to your project, don't do it through VS, but add it to the .PRO file and re-run qmake.
The only thing (that I've found) is if you change anything that needs to be MOC'd, then re-run qmake.
If you want CMake exclusively then this is a nice guide
http://www.kdab.com/using-cmake-with-qt-5/.
The qmake way is a little cleaner as you don't get all the extra noise of finding Qt libraries as you need in CMake.

Can I have a C# solution with GTK that can be used in both Visual Studio and MonoDevelop/Xamarin Studio?

I created a C# solution with Xamarin Studio (on Mac) that uses GTK. When I clone that to Windows and open it in Visual Studio, I'm disappointed to see that all the GTK references are broken.
In Xamarin, I see that the GTK libraries are in the Mono Framework, and not just simple dlls. The references point to paths in /Library/Frameworks/Mono.framework/' according to the UI, but in the underlying.csproj` file, there is no path at all.
In Visual Studio, those references are broken, and the paths are empty. The Mono for Windows installer (mono-3.2.3-gtksharp-2.12.11-win32-0.exe, in my case) does not add the GTK libs to the GAC (which seems like a dumb thing to not do).
Is there a way to get GTK# recognized by Visual Studio in a way that doesn't break the project for Xamarin Studio?
Either install Xamarin Studio on the Windows machine or install GTK# by itself. You will not be able to design UI from Visual Studio but you will be able to build it and debug/run it.
http://www.go-mono.com/mono-downloads/download.html

How to choose Visual Studio solution Platform Toolset for maximum compatibility

Background
I am open sourcing a few old Visual Studio applications I created a while back. I have created new solutions using my new VS2012 environment for them and have gotten the projects set up as git repositories. I got everything working fine in Visual Studio 2012 with no changes to the source code, all I needed to do was make sure I was linking the proper libraries in the new project configurations.
I would like to configure these projects as to have maximum compatibility for others downloading the project from Github. On this machine I have VS2010 installed alongside the latest VS2012 version. After I got everything working right for both of the projects in VS2012, I tried to open them up in VS2010.
When I tried to build I got a single error:
Specified platform toolset (v110) is not installed or invalid.
Please make sure that a supported PlatformToolset value is selected.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets 518
What I Tried
So I opened up the properties for the project, went to Configuration Options --> General and the Platform Toolset was indeed set to Visual Studio 2012 (v110). This input is a drop down box and the v110 value is not listed, instead I get two choices:
v100
v90
These correspond to VS2010 and VS2008 respectively. If I change the value to v100 and rebuild I get no errors and my program runs just fine in my Visual Studio 2010 environment.
When I open the project back up in Visual Studio 2012, if tells me that I have an old project file and asks if I want to upgrade, I say yes and it upgrades. I rebuild and run to make sure everything is still working. When I open the configuration options in VS2012 the Platform Toolset is set back to `Visual Studio 2012 (v110) but clicking the drop down input there are several more choices listed:
Visual Studio 2012 (v110)
v110_wp80
Visual Studio 2012 - Windows XP (v110_xp)
Visual Studio 2010 (v100)
Visual Studio 2008 (v90)
‹inherit from parent or project defaults›
My Questions
This has led me to several questions. I am going to pose them all. It would be nice to get as much information as I can, but a good answer to just one of them would probably solve my problem.
If I'm not using features specific to newer versions of Visual Studio, is it possible to set up a solution which can be opened and run without modification in as many versions as possible (ie. 2008, 2010, or 2012)? If so, how?
If I set the Platform Toolset to v90 (VS2008) from within Visual Studio 2012, and it's able to build and run, does this mean that it will build and run for users with VS2012, VS2010, and VS2008?
What exactly does the <inherit for parent or project defaults> option do? What would the project defaults be set up as? Can this be used to tell Visual Studio to try to using whichever installed Platform Toolset will work.
Are there any other options besides Platform Toolset in Visual Studio that I can set to increase compatibility with others' development environments?
This is a somewhat tricky situation. One of the underlying problems here is that VS2010 and VS2012 use MSBuild to build C++ projects, but VS2008 farmed it out to VCBuild instead. You can see this by comparing the project files. VS2010/VS2012 use .vcxproj, while VS2008 uses .vcproj.
If I'm not using features specific to newer versions of Visual Studio,
is it possible to set up a solution which can be opened and run
without modification in as many versions as possible (ie. 2008, 2010,
or 2012)? If so, how?
For maximum compatibility, you want to target the lowest common denominator (i.e. vc90 in this case). Note that when you do the upgrade, the solution file and project files get upgraded to the latest version, which may break compatibility with older versions of Visual Studio.
If I set the Platform Toolset to v90 (VS2008) from within Visual
Studio 2012, and it's able to build and run, does this mean that it
will build and run for users with VS2012, VS2010, and VS2008?
Not really, due to the .vcxproj / .vcproj conflict stated above.
For example, I currently have a set of .vcxproj files and a solution designed for VS2010. I use VS2012 as my IDE, so when I open the VS2010 solution in VS2012, I choose to NOT upgrade it and simply open it as is. VS2012 and beyond should be backwards compatible back to VS2010 as far as project files go.
For maximum compatibility in development environments, my recommendation would be use VS2010's solution as the baseline, targeting v100. Developers can use any version newer than that and it should all work together gracefully.

Resources