Skip to content
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

Support hot reloading with Inject #1710

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

mplorentz
Copy link
Member

@mplorentz mplorentz commented Dec 27, 2024

Description

This adds a framework for hot reloading to Nos. I tried it out in my hackathon project and thought it might be useful as a faster, more reliable alternative to SwiftUI previews.

How to test

  1. Follow the new instructions to set up hot reloading in the CONTRIBUTING.md.
  2. Run the Nos scheme in the simulator.
  3. (Optional) open the console log and filter it by "💉" to see the Inject logs. If you set it up correctly you should see something like:
💉 InjectionIII connected /Users/matt/v/nos/Nos.xcodeproj
💉 Watching files under the directory /Users/matt/v/nos`

If not, maybe you need to watch the correct directory from the InjectionIII menubar app.

  1. Open HomeFeedView
  2. Change the background color to something bright like red
  3. Hit command-s to save. You should see Inject recompile the file in the logs
  4. For some reason our views don't update right away, but if you tap another tab and then tap the home tab again the background color should change.

Screenshots/Video

(ignore the fact that in the video the simulator is showing my hackathon branch)

Screen.Recording.2024-12-27.at.10.00.28.AM.mov

@mplorentz mplorentz marked this pull request as draft December 27, 2024 15:08
@mplorentz
Copy link
Member Author

shoot this is on the wrong branch. I will have to fix it later.

@mplorentz mplorentz force-pushed the hot-reloading-with-inject branch from 0c57bd1 to 0dd8f24 Compare December 27, 2024 18:43
@@ -53,6 +53,10 @@ For now `main` is the main branch and code improvements are made in topic branch

A maintainer will review your code and merge it when it has the required number of approvals.

## Hot Reloading

We make use of the [Inject](https://github.com/krzysztofzablocki/Inject) framework for hot reloading debug builds. To set up hot reloading, follow the [documentation](https://github.com/krzysztofzablocki/Inject?tab=readme-ov-file#individual-developer-setup-once-per-machine).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this documentation is too light, but I am kinda rushing to throw this PR out there. Maybe the reviewer can tell me if it's enough or document the steps they had to take.

For instance, the first thing their documentation says to do is add some linker flags which is already done. So at least that part is superfluous. It's been a while since I set this up so I don't remember what I did exactly.

@mplorentz mplorentz marked this pull request as ready for review December 27, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant