Inject: TCA 1.7.3 crash (ComposableArchitecture/Store.swift:682: Fatal error: Unexpectedly found nil while unwrapping an Optional value)

I’m trying to use this package with TCA 1.7.3, however when a non-leaf view is changed the app crashes. I’ve created an example project for this: InjectTCATest. In the linked project if I change the Text("AppFeature") in AppView to Text("AppFeature2") there’s a crash:

πŸ’‰ InjectionIII connected /Users/kuglee/Downloads/InjectTCATest/InjectTCATest.xcodeproj
πŸ’‰ Watching files under the directory /Users/kuglee/Downloads/InjectTCATest
πŸ’‰ Compiling /Users/kuglee/Downloads/InjectTCATest/InjectTCATest/AppFeature.swift
πŸ’‰ Selecting Xcode /Applications/Xcode-beta.app/Contents/Developer
πŸ’‰ Loading .dylib ...
πŸ’‰ Interposed 15 function references.
πŸ’‰ Injected type #1 'InjectTCATest.AppFeature'
πŸ’‰ Injected type #2 'InjectTCATest.AppFeature.State'
πŸ’‰ Injected type #3 'InjectTCATest.AppFeature.Action'
πŸ’‰ Injected type #4 'InjectTCATest.AppFeature.Action.AllCasePaths'
πŸ’‰ Injected type #5 'InjectTCATest.AppView'
ComposableArchitecture/Store.swift:682: Fatal error: Unexpectedly found nil while unwrapping an Optional value
crash

If I change the Text("ChildFeature") in ChildView to Text("ChildFeature2") it works as expected.

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

Great! Yes, this one was a real time consumer but having the Feature and View in the same file is the norm for TCA so I really wanted to be sure it worked even if people have to remember to opt in with the env var for now. There will be limits and if you run up against something let me know. If you don’t, remember there’s a tip jar on the InjectionIII project!