macOS development.tutorial 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. @Tutorial {
  2. @Intro(title: "Setting up a development environment on macOS") {
  3. Detailed set up instructions for macOS-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 Xcode") {
  8. @ContentAndMedia {
  9. Even if you don't use the editor, you still need to have
  10. [Xcode](https://developer.apple.com/xcode/) installed on your system since it bundles
  11. the macOS and iOS SDKs.
  12. If you already have a reasonably up-to-date copy of Xcode, you can skip this section.
  13. }
  14. @Steps {
  15. Installing Xcode from the App Store is trivial:
  16. @Step {
  17. Visit Xcode's [App Store page](https://apps.apple.com/us/app/xcode/id497799835?mt=12/)
  18. and click Get.
  19. @Image(source: macOS-01-01, alt: "An App Store window showing Xcode's page.")
  20. }
  21. For more flexibility, you can also choose to install Xcode manually. Doing it like this
  22. also lets you install directly to an external storage device, which can come in handy if
  23. you're running low on storage.
  24. @Step {
  25. Locate your desired Xcode release on [xcodereleases.com](https://xcodereleases.com).
  26. @Image(source: macOS-01-02, alt: "A browser window showing xcodereleases.com.")
  27. }
  28. @Step {
  29. Click Download and wait for it to finish (Xcode is pretty huge, so it'll take a
  30. while). Sign in with your Apple Account if prompted.
  31. }
  32. @Step {
  33. Unzip the `.xip` file.
  34. Archive Utility works fine in a pinch, but we recommend using
  35. [unxip](https://github.com/saagarjha/unxip) instead; it's faster and it doesn't use
  36. temporary storage on your internal drive (which is useful if you're low on storage).
  37. }
  38. @Step {
  39. Move `Xcode.app` to wherever you want it, usually either `/Applications` or some
  40. external location.
  41. }
  42. @Step {
  43. Open Xcode, accept the license agreement if it prompts you, and select the SDKs you
  44. need when it prompts you to install optional components.
  45. }
  46. @Step {
  47. If you put Xcode in a location other than `/Applications/Xcode.app`, run
  48. `xcode-select --switch /path/to/Xcode.app`.
  49. @Code(name: "XcodeSelect.shell", file: macOS-01-07.shell)
  50. }
  51. }
  52. }
  53. @Section(title: "Installing Swift Bundler") {
  54. @ContentAndMedia {
  55. [Swift Bundler](https://swiftbundler.dev) unifies your cross platform development
  56. experience with a consistent CLI interface and configuration format.
  57. }
  58. @Steps {
  59. @Step {
  60. Install Swift Bundler via whatever means you prefer.
  61. Swift Bundler's [documentation](https://swiftbundler.dev/documentation/swift-bundler/installation)
  62. lists a wide variety of installation methods, but if you have Mint installed it's as
  63. easy as running `mint install moreSwift/swift-bundler@main`.
  64. }
  65. @Step {
  66. Once installed, run `swift-bundler --version` as a quick sanity check.
  67. @Code(name: "SwiftBundler.shell", file: swift-bundler-version.shell)
  68. }
  69. And that's it! If you're only using <doc:AppKitBackend> and <doc:UIKitBackend> when
  70. targeting Apple platforms, then you're good to go.
  71. If you'd like to test your app with <doc:GtkBackend> or <doc:Gtk3Backend> without
  72. leaving your Mac, visit the backends' respective documentation pages for detailed
  73. dependency installation instructions.
  74. }
  75. }
  76. }