Skip to content

Workspace/InitPackage: Add .vscode to .gitignore #8164

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

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

czechboy0
Copy link
Member

Motivation:

When using VS Code, this directory gets created, but generally isn't meant to be checked in, similar to Xcode' xcuserdata.

Modifications:

Added .vscode to the generated .gitignore for new packages.

Result:

When creating a new package, when an adopter uses VS Code, they won't have to add this entry into their .gitignore by hand.

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov changed the title [Init] Add .vscode to .gitignore Workspace/InitPackage: Add .vscode to .gitignore Dec 9, 2024
@MaxDesiatov MaxDesiatov added enhancement swift package init Package templates command changes workspace Package workspace support labels Dec 9, 2024
@plemarquand plemarquand enabled auto-merge (squash) December 9, 2024 12:27
@plemarquand plemarquand merged commit 891f578 into swiftlang:main Dec 9, 2024
5 checks passed
@czechboy0 czechboy0 deleted the hd-add-vscode-to-gitignore branch December 9, 2024 12:56
@dschaefer2
Copy link
Member

I always wondered that. There are somethings in there that could be shared. Given Paul merged it, I'll assume that you are correct :).

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Dec 9, 2024

yeah, I now remember it's vscode/launch.json something or other always auto-generated, but maybe there's not much else maintained manually in most repositories to track?

@dschaefer2
Copy link
Member

You can add more launch configurations by hand. I do that when running SwiftPM with various options when testing. Also the tasks.json has the build configurations which I sometimes change to add verbosity, etc.

Mind you it's a problem with VSCode that those things aren't separated out to user and shared like Xcode does.

@plemarquand
Copy link
Contributor

I may have been too quick to automerge this. While its true that there are some things in .vscode that you may not want to commit it is still useful to have {settings,tasks,launch,extensions}.json checked in to share configuration with your team.

As a result may want more granularity here than just all of .vscode. See this example .gitignore: https://www.toptal.com/developers/gitignore/api/visualstudiocode

@MahdiBM
Copy link

MahdiBM commented Dec 9, 2024

Like @dschaefer2 mentions, you can manually add stuff to vscode/launch.json, like creating new Xcode schemes with specific env vars etc... we do use this in a team project.
There are also some other files like extensions.json (e.g. for extension recommendations to install) and settings.json to share workspace settings.

In a few projects Swift that I've set up VS Code on, we do share all those files out of necessity.

I can see how you might not want to share some of the files, but ... I think you should? I'm not a huge VS Code user so not sure what is the consensus in their community, but sharing these files in a few teams, they have only been helpful.

For example when sharing settings.json, if there is settings that different users don't agree on, then you simply should remove that setting from settings.json, and let VS Code fallback to user settings.

Using settings.json you can for example set the settings for formatters of each filetype, or indentation settings, so contributors can easily work on the project without violating the project's general style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement swift package init Package templates command changes workspace Package workspace support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants