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

fix: crash in MVVM Example #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

humblehacker
Copy link

Example app crashes after pressing login. In DefaultLoginViewModel.login(), router is nil. I tracked this down to RouterStore.retrieve() failing to cast the stored object. This is due to the line fixed in this commit - DefaultLoginViewModel.router had the wrong type declared.

Screen Shot 2022-03-22 at 5 49 14 PM

Thread 3 Queue : com.apple.root.user-initiated-qos.cooperative (serial)
#0	0x000000018f97bc04 in _swift_runtime_on_report ()
#1	0x000000018fa01594 in _swift_stdlib_reportFatalErrorInFile ()
#2	0x000000018f6dd21c in closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#3	0x000000018f6dcf84 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#4	0x000000018f6dc954 in _assertionFailure(_:_:file:line:flags:) ()
#5	0x00000001004c3fc8 in DefaultLoginViewModel.login() at /Users/david/src/other/stinsen/Examples/MVVM/Shared/Login/ViewModels/DefaultLoginViewModel.swift:23
#6	0x00000001004c4658 in protocol witness for LoginViewModel.login() in conformance DefaultLoginViewModel ()
#7	0x00000001004cb04c in closure #1 in closure #1 in closure #1 in LoginView.body.getter at /Users/david/src/other/stinsen/Examples/MVVM/Shared/Login/View/LoginView.swift:34
#8	0x00000001004cde74 in partial apply for closure #1 in closure #1 in closure #1 in LoginView.body.getter ()
#9	0x00000001004ce0a0 in thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out τ_0_0) ()
#10	0x00000001004ce204 in partial apply for thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out τ_0_0) ()

Example app crashes after pressing login. In `DefaultLoginViewModel.login()`, `router` is nil. I tracked this down to `RouterStore.retrieve()` failing to cast the stored object. This is due to the line fixed in this commit - `DefaultLoginViewModel.router` had the wrong type declared.
@mevdev
Copy link

mevdev commented May 9, 2022

The example works now without error, but the test still fails.

It appears as if it wants to use the MockLoginCoordinator, but it is still getting the DefaultAuthenticatedCoordinator from DefaultLoginCoordinator.makeAuthenticated().

@mevdev
Copy link

mevdev commented May 9, 2022

In the file 'DefaultLoginViewModel' change line 17 to
@RouterObject var router: NavigationRouter<LoginCoordinator>!
And the test will pass.

@crisanvlad
Copy link

make the init of the RouterStore lazy

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.

3 participants