krzysztofzablocki / Inject

Hot Reloading for Swift applications!
MIT License
2.14k stars 114 forks source link

Not updating in simulator #16

Closed okla closed 2 years ago

okla commented 2 years ago

I have a simple SwiftUI project (2 files), everything is installed and set up, I see all the messages from InjectionIII in console. But changes that I make in views do not appear in simulator.

johnno1962 commented 2 years ago

What does the debug console say? Are you watching the correct directory? Did you add an injectionObserver?

okla commented 2 years ago

Yes, imported Inject, added Observer and called enableInjection(). Console shows correct messages, same as here https://github.com/krzysztofzablocki/Inject#individual-developer-setup-once-per-machine

johnno1962 commented 2 years ago

Very difficult to say what the problem would be. Are you able to zip up the project and post it?

johnno1962 commented 2 years ago

Have you added "Other Linker Flags" "-Xlinker -interposable" to the project?

okla commented 2 years ago

Yes, flags are added. I will try to prepare a test project tomorrow.

wojciech-kulik commented 2 years ago

I had today the same problem when I switched from the InjectionIII app installed manually to InjectionIII installed from App Store. Not sure what was the problem. Files were recompiled correctly, but the view was not refreshing. I switched back to the previous version and it works again.

johnno1962 commented 2 years ago

Interesting, this could be something to do with the defaults remembering the selected project. If in doubt, select the project directory again using menu item "Open Project" & I'll have a look at the code. The question is when you save a file do you see the message "Compiling ...", "Injected Type ..." etc.

wojciech-kulik commented 2 years ago

@johnno1962 I tried with "Open Project" and cleaned up settings, still doesn't work. I noticed this version works more slowly and produces this warning:

Class _TtC10MyModule39MyFile is implemented in both /MyApp/Smth (0x112eb1b58) and /private/var/folders/c3/fn8391xj715ccg2w6bcv8s8w0000gn/T/com.johnholdsworth.InjectionIII/eval101.dylib (0x194ec9010). One of the two will be used. Which one is undefined

I guess that's the problem because I debugged the app and it reloads the view, however the app doesn't see changes.

krzysztofzablocki commented 2 years ago

It's better to use the github version of Injection app @wojciech-kulik because it's newest and @johnno1962 often cuts new updates as we extend the tool, appstore version has longer release cycle

amadeuszpolak commented 2 years ago

same problem here ... I have created a swiftUI testApp and it doesn't work.

Screenshot 2022-04-08 at 09 25 44 Screenshot 2022-04-08 at 09 26 13

I got error about "-Xlinker -interposable" flags but as you can see on the SS it is added. Any advices ? I use the newest version of Xcode.

krzysztofzablocki commented 2 years ago

@amadeuszpolak does the example app work for you?

johnno1962 commented 2 years ago

@amadeuszpolak, any chance you could zip up your example app and post it here or email it to me: github at johnholdsworth.com. This is bound to be something simple but at a loss to say what it would be.

amadeuszpolak commented 2 years ago

I have watched the video and the reason was that I added those flags to the Project and not to the target. Now it works ;) thanks guys !

johnno1962 commented 2 years ago

Great news! @okla, could this be your problem?

okla commented 2 years ago

@johnno1962 Yep, that was the problem, everything works now!

johnno1962 commented 2 years ago

Hurrah!