-
Notifications
You must be signed in to change notification settings - Fork 84
Add Remote Development docs #101
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
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dc04b3f
Add remote dev docs
0xTim 1218707
Add link to docs to README
0xTim 6729170
Update docs/remote-dev.md
0xTim 0e014f7
Remove docs top level README
0xTim 62b4ee3
Address code review comments
0xTim 2a003df
Add link to new doc in README
0xTim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Visual Studio Code Remote Development | ||
|
||
[VSCode Remote Development](https://code.visualstudio.com/docs/remote/containers) allows you to run your code and environment in a container. This is especially useful for Swift when developing on macOS and deploying to Linux. You can ensure there are no compatibility issues in Foundation when running your code. | ||
|
||
## Requirements | ||
|
||
As well as installing the Swift extension, you must install Docker on your machine to run the remote container in. See the [Visual Studio Code documentation](https://code.visualstudio.com/docs/remote/containers) for more details. | ||
|
||
Next, install the [Remote Development extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) that contains extensions for working in remote environments in VSCode. If you only want to work with remote containers (and not use the SSH or WSL containers), you may want to only install the [Remote Development Container extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) instead. | ||
|
||
## Running in a container | ||
|
||
### Manual Setup | ||
|
||
VSCode requires a `.devcontainer` directory which defines the settings in `devcontainer.json` and optionally a `Dockerfile` defining the container to run in. | ||
|
||
First create the directory. Next, create `devcontainer.json` and insert the following: | ||
|
||
```json | ||
{ | ||
"name": "Swift 5.5", | ||
"image": "swift:5.5", | ||
"extensions": [ | ||
"sswg.swift-lang", | ||
], | ||
"settings": { | ||
"lldb.library": "/usr/lib/liblldb.so" | ||
}, | ||
"forwardPorts": [8080] | ||
} | ||
``` | ||
|
||
This defines the minimum settings required to run a Swift package in a remote container. Here's what each thing does: | ||
|
||
* `name`: Used to specify the name of the remote container. | ||
* `image`: The Docker container image to run. You can choose whichever version of Swift you like, including [nightlies](https://hub.docker.com/r/swiftlang/swift). | ||
* `extensions`: Extensions to install in your remote environment. You do not need to specify extensions' dependencies, such as LLDB. | ||
* `settings`: Override any settings for extensions. The above example sets the LLDB path to stop the Swift extension from attempting to set it up. | ||
* `forwardPorts`: Ports to enable forwarding for. You may want to include this if building a Swift server application for example. | ||
|
||
That's all you need to get a dev container working! | ||
|
||
#### Using a custom Dockerfile | ||
|
||
You may want to use a custom Docker container that's version controlled to make it easy to set up a development environment for you team. In `devcontainer.json` replace `image` with the following: | ||
|
||
```json | ||
{ | ||
"build": { "dockerfile": "Dockerfile" }, | ||
// ... | ||
} | ||
``` | ||
|
||
This will use the `Dockerfile` provided in `.devcontainer`. Create that file and insert your custom Dockerfile. For example: | ||
|
||
```docker | ||
FROM swift:5.5 | ||
``` | ||
|
||
<!-- ### Automatic Setup | ||
|
||
VSCode allows you to automatically configure your project with a dev container. In the command palette (`F1`) choose **Remote-Containers: Add Development Container Configuration Files...** and choose Swift. --> | ||
|
||
### Running in a container | ||
|
||
Once you've set up your `.devcontainer`, in the command palette run **Remote-Containers: Reopen in Container**. VSCode will relaunch running in your remote container! | ||
|
||
For more details about running your project in a remote container, and the available configuration options, see the [Visual Studio Code documentation](https://code.visualstudio.com/docs/remote/remote-overview). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.