hmlongco / Resolver

Swift Ultralight Dependency Injection / Service Locator framework
MIT License
2.14k stars 188 forks source link

Fatal Error: FIRFirestore not resolving #88

Closed hferrone closed 3 years ago

hferrone commented 3 years ago

Hi!

I'm having a problem using Resolver in my iOS + Firebase project. When I run my app, I get the following error:

Fatal error: RESOLVER: 'FIRFirestore:' not resolved. To disambiguate optionals use resolver.optional().: file Resolver/Resolver.swift, line 222.

I've read your docs on optionals, and I don't have any in my project that relate to the services I've registered:

Screen Shot 2021-01-18 at 9 30 35 PM Screen Shot 2021-01-18 at 9 31 25 PM Screen Shot 2021-01-18 at 9 31 34 PM

For reference, I've been following this wonderful tutorial by someone who works at Firebase: https://peterfriese.dev/replicating-reminder-swiftui-firebase-part2/

I'm not sure if I'm just misunderstanding the way injected variables work, or how DI files are resolved behind the scenes. Any help would be greatly appreciate!

Cheers,

Harrison Ferrone

hmlongco commented 3 years ago

Attempting to use resolve() on an optional (or implicitly unwrapped optional) is a common reason for service resolution to fail, which is why it's mentioned at that point.

At first glance, it looks like you registered FirestoreRepository and SessionStore, but in the repository you're also injecting db: Firestore but I'm not seeing a registration for that. Everything you attempt to inject or resolve must be registered.

Doing a stack trace on the crash should show which injection is failing.