Linux development.tutorial 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. @Tutorial {
  2. @Intro(title: "Setting up a development environment on Linux") {
  3. Detailed set up instructions for Linux-based development environments.
  4. In this article we'll focus on developing SwiftCrossUI apps with Swift Bundler, but much of
  5. the information should still apply if you choose to use a different build system.
  6. }
  7. @Section(title: "Installing Swift") {
  8. @ContentAndMedia {
  9. With the release of [swiftly](https://github.com/swiftlang/swiftly), the official Swift
  10. toolchain manager, installing Swift toolchains on Linux has become much easier. That
  11. said, there are still a few things to watch out for when using less mainstream Linux
  12. distributions. If Swiftly doesn't work for you, feel free to use an alternative
  13. installation method as found in the
  14. [installation instructions](https://www.swift.org/install/linux).
  15. If you already have Swift installed, you can skip this section.
  16. }
  17. @Steps {
  18. @Step {
  19. Follow the official Swiftly-based
  20. [installation instructions](https://www.swift.org/install/linux).
  21. }
  22. @Step {
  23. Restart your shell to ensure Swift is in your PATH, then double-check it's been
  24. installed correctly by running `swift --version`.
  25. @Code(name: "SwiftVersion.shell", file: linux-01-02)
  26. }
  27. > Tip: If your Linux distribution isn't officially supported, check out
  28. > [`xtremekforever`'s post on the Swift Forums](https://forums.swift.org/t/running-swift-on-unsupported-distributions/71741).
  29. > It contains a table that tells you which distribution to select in Swiftly, or in the
  30. > swift.org downloads section, in order to maximize the chance of things working on your
  31. > chosen distribution. The best distribution to download isn't always the most
  32. > intuitive.
  33. }
  34. }
  35. @Section(title: "Installing Swift Bundler") {
  36. @ContentAndMedia {
  37. [Swift Bundler](https://swiftbundler.dev) unifies your cross platform development
  38. experience with a consistent CLI interface and configuration format.
  39. }
  40. @Steps {
  41. @Step {
  42. Install Swift Bundler via whatever means you prefer.
  43. Swift Bundler's [documentation](https://swiftbundler.dev/documentation/swift-bundler/installation)
  44. lists a wide variety of installation methods, but if you have Mint installed it's as
  45. easy as running `mint install moreSwift/swift-bundler@main`.
  46. }
  47. @Step {
  48. Once installed, run `swift-bundler --version` as a quick sanity check.
  49. > Important: If you're coming from macOS, you'll have to adjust your habits because
  50. > `swift bundler` with a space instead of a hyphen doesn't work on Linux.
  51. @Code(name: "SwiftBundler.shell", file: swift-bundler-version.shell)
  52. }
  53. }
  54. }
  55. @Section(title: "Installing Gtk") {
  56. @ContentAndMedia {
  57. The final step is to install the dependencies for the backend you'll be using.
  58. On Linux you're limited to <doc:GtkBackend> and <doc:Gtk3Backend>. We recommend using
  59. <doc:GtkBackend> unless you have a really good reason not to; <doc:Gtk3Backend> exists
  60. solely to support older Linux distributions, and doesn't support as many features.
  61. }
  62. @Steps {
  63. > Tip: Some distributions such as Ubuntu 22.04 allow you to install both Gtk 3 and
  64. Gtk 4. This can come in handy when you have to target both backends.
  65. @Step {
  66. Check the documentation for either <doc:GtkBackend> or <doc:Gtk3Backend> for
  67. detailed installation instructions.
  68. }
  69. }
  70. }
  71. }