Flutter google Maps ios build fail

968

You've replaced UIApplication.LaunchOptionsKey with UIApplicationLaunchOptionsKey in the function signature. Replace it back to fix the error

Share:
968
Karel Debedts
Author by

Karel Debedts

Updated on December 16, 2022

Comments

  • Karel Debedts
    Karel Debedts over 1 year

    I'm trying to implement google maps in my flutter app. I'm using this version:

      google_maps_flutter: ^0.5.21+15
    

    It works on android, but on ios there's a build fail when trying.

    I discovered this:

    normally my AppDelegate.swift looks like this:

    import UIKit
    import Flutter
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
    

    But when I use this, as the google maps plugin says, the build fails:

    import UIKit
    import Flutter
    import GoogleMaps
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
      ) -> Bool {
        GMSServices.provideAPIKey("YOUR KEY HERE")
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
    

    What Am I doing wrong?

    Thanks for helping!

    Just in case, this is my pubspec yaml

      cupertino_icons: ^0.1.2
      firebase_core: ^0.4.3+1
      firebase_auth: ^0.15.2
      cloud_firestore: ^0.13.0+1
      firebase_database: ^3.1.1
      cloud_functions: ^0.4.1+6
      firebase_messaging: ^6.0.9
      firebase_storage: ^3.1.0
      google_sign_in: ^4.1.0
      flutter_facebook_login: ^3.0.0
      geolocator: ^5.1.5
      shared_preferences: ^0.5.6
      url_launcher: ^5.4.1
      rflutter_alert: ^1.0.3
      font_awesome_flutter: ^8.5.0
      flutter_picker: ^1.1.0
      uuid: ^2.0.4
      image_picker: ^0.6.2+3
      path_provider: ^1.5.1
      image: ^2.1.4
      flutter_datetime_picker: ^1.2.8
      intl: ^0.16.0
      native_contact_picker: ^0.0.6
      flutter_spinkit: ^4.1.1+1
      transparent_image: ^1.0.0
      connectivity: ^0.4.6+1
      flare_splash_screen: ^3.0.0
      algolia: ^0.1.7
      http: ^0.12.0+2
      avatar_glow: ^1.1.0
      rxdart: ^0.22.2
      auto_size_text: ^2.1.0
      camera: ^0.5.7+2
      video_player: ^0.10.5
      story_view: ^0.11.0
      image_crop: ^0.3.1
      file_picker: ^1.4.3+1
      pdf_viewer_plugin: ^1.0.0+2
      flutter_background_geolocation: ^1.4.5
      location_permissions: ^2.0.3
      image_downloader: ^0.19.1
      permission_handler: ^4.0.0
      google_maps_flutter: ^0.5.21+15
    

    And this is the error I get:

     /Users/kareldebedts/myapp/ios/Runner/AppDelegate.swift:7:17: error: method does not override any method from its superclass
          override func application(
          ~~~~~~~~      ^
        note: Using new build system
        note: Planning build
        note: Constructing build description
        warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
        warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
        warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'camera' from project 'Pods')
        warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'camera' from project 'Pods')
    
    Could not build the application for the simulator.
    Error launching application on iPhone 11 Pro Max.
    
  • Pavel
    Pavel over 4 years
    FYI you can use some diff tool to find all places which are different in two code snippets
  • Karel Debedts
    Karel Debedts over 4 years
    Thanks! very strange, cuz I got the snippet from the official google maps package on flutter. But it works! Thanks!