Skip to content

Conversation

@AlexanderStrup
Copy link

I created flutter module to use it as library in native app. I used your plugin to get contacts. But I had runtime error in native app when tried to register plugins
GeneratedPluginRegistrant.register(with: flutterEngine);

SwiftContactsServicePlugin.swift:16: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Line 16 in SwiftContactsServicePlugin.swift: 
let rootViewController = UIApplication.shared.delegate!.window!!.rootViewController!;

I did it according Flutter Docs to interaction with my module. I tried add window variable to my AppDelegate but it didn't help.
iOS 13+ has new methods and classes for getting window. With my changes I got the rootViewController but I think the runtime error is bad practice anyway so just add an error message to log when rootViewController still nil.

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.

2 participants