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

Unexpected nil value when configuring flutter_config_plus package in AppDelegate.swift #1

Open
Mahm0ud-Ahmed opened this issue May 17, 2023 · 1 comment

Comments

@Mahm0ud-Ahmed
Copy link

Issue Description: Unexpected nil value when configuring flutter_config_plus package in AppDelegate.swift

Steps to Reproduce:

Integrate the flutter_config_plus package into a Flutter project.
Open the AppDelegate.swift file.
Configure the package by adding the necessary code as instructed in the package documentation.
Run the project on iOS.
Expected Behavior:

The flutter_config_plus package should be successfully configured, and the necessary values should be retrieved from the configuration file or environment variables.

Actual Behavior:

Upon running the project on iOS, a fatal error is encountered with the following error message:

Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file Runner/AppDelegate.swift, line 13

Additional Information:

The error occurs on line 13 of the AppDelegate.swift file where the FlutterConfigPlusPlugin.env(for: "IOS_GOOGLE_MAP_API_KEY") method is called.
The IOS_GOOGLE_MAP_API_KEY is an environment variable set for the project, and it is expected to provide the necessary API key for Google Maps.
The error suggests that the optional value returned by FlutterConfigPlusPlugin.env(for:) is nil and is being force-unwrapped, resulting in the crash.

AppDelegate.swift file

import UIKit
import Flutter
import GoogleMaps
import flutter_config_plus

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey(FlutterConfigPlusPlugin.env(for: "IOS_GOOGLE_MAP_API_KEY"));
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
@stevennguyenn
Copy link
Owner

Did you setup release.xcconfig or debug.xcconfigfile ?

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

No branches or pull requests

2 participants