sweetpad-dev / sweetpad

Develop Swift/iOS projects using VSCode
https://marketplace.visualstudio.com/items?itemName=sweetpad.sweetpad
MIT License
586 stars 19 forks source link

Support HotReload? #59

Closed sunshineLixun closed 2 weeks ago

sunshineLixun commented 1 month ago

Thank you for developing this plugin, I like it very much. In practice, I encountered a bad experience: every time I modify the code, I have to go back to XCode to execute Common + R and re-run the simulator. Is there a better way to solve this experience problem, or can it support XCode Canvas Preview hot reload? Although this is indeed a bit difficult, it can greatly improve development efficiency. Thank you.

rudrankriyam commented 1 month ago

Have Cursor on the left on top of Xcode with only previews showing; any changes made in Cursor after saving will be reflected in previews.

For easily running on a simulator, use keyboard bindings. Here is an example:

[
  {
    "key": "ctrl+alt+cmd+b",
    "command": "workbench.action.toggleSidebarVisibility"
  },
  {
    "key": "cmd+b",
    "command": "-workbench.action.toggleSidebarVisibility"
  },
  {
    "key": "cmd+b",
    "command": "runCommands",
    "args": {
      "commands": [
        {
          "command": "workbench.action.tasks.terminate",
          "args": "terminateAll"
        },
        {
          "command": "workbench.action.tasks.runTask",
          "args": "sweetpad: build"
        }
      ]
    }
  },
  {
    "key": "ctrl+cmd+r",
    "command": "runCommands",
    "args": {
      "commands": [
        {
          "command": "workbench.action.tasks.terminate",
          "args": "terminateAll"
        },
        {
          "command": "sweetpad.build.launch"
        }
      ]
    }
  },
  {
    "key": "cmd+.",
    "command": "runCommands",
    "args": {
      "commands": [
        {
          "command": "workbench.action.terminal.killAll"
        }
      ]
    },
    "when": "inDebugMode || taskRunning"
  }
]

I hope that will greatly improve development efficiency!

sunshineLixun commented 1 month ago

Thank you for your reply. I found this library: https://github.com/krzysztofzablocki/Inject which can hot reload SwiftUI. With your sweetpad, the development experience is greatly improved. Thank you for your work.

rudrankriyam commented 1 month ago

All credits for Sweetpad goes to @hyzyla!