How to correctly implement Amplify to Flutter

1,139

You want to change import 'package:amplify_core/amplify_core.dart' to import 'package:amplify_flutter/amplify.dart'; then when you add your plugins you'll wanna do it like this Amplify.addPlugins([authPlugin, storage]);

I also ran flutter upgrade before I did this as well just make sure you save all your changes. You can find more information in there example flutter app

https://github.com/aws-amplify/amplify-flutter/blob/master/example/lib/main.dart

Share:
1,139
Admin
Author by

Admin

Updated on December 27, 2022

Comments

  • Admin
    Admin over 1 year

    for the last few days, I was trying to figure out how to fix the issues I was having with Amplify for Flutter: error: compiling for iOS 9.0, but module 'Starscream' has a minimum deployment target of iOS 11.0 and Target of URI doesn't exist: 'package:amplify_core/amplify_core.dart'

    Things I tried:

    1. Following the tutorial of the doc https://docs.amplify.aws/start/getting-started/setup/q/integration/flutter. That resulted in: project directory/ios/Pods/AppSyncRealTimeClient/AppSyncRealTimeClient/Connection/AppSyncConnection/AppSyncSubscriptionConnection+ErrorHandler.swift:9:8: error: compiling for iOS 9.0, but module 'Starscream' has a minimum deployment target of iOS 11.0: project directory/build/ios/Debug-iphonesimulator/Starscream/Starscream.framework/Modules/Starscream.swiftmodule/x86_64-apple-ios-simulator.swiftmodule and Command CompileSwift failed with a nonzero exit code note: Using new build system note: Building targets in parallel note: Planning build note: Contructing build description. I uncommented the line platform :ios, '9.0' on Podfile and changed it to platform :ios, '11.0', while also changing the development target to 11 on the projects xcworkspace. The same error happened.

    2. Following the tutorial of the doc https://aws.amazon.com/getting-started/hands-on/build-flutter-app-amplify/. That resulted in:Target of URI doesn't exist: 'package:amplify_core/amplify_core.dart' when I tried to import the core. Like that, I couldn't use the Amplify() class.

    3. Restarting the computer.

    4. Deleting the Amplify folder.

    5. Running amplify uninstall, and trying from the start again.

    6. Searching other posts on this and other websites.

    7. Running amplify clean.

    Things to note:

    1. The Amplify installation, init, and configure steps returned no errors.
    2. If I delete the Amplify dependencies amplify_flutter: '<1.0.0' amplify_auth_cognito: '<1.0.0' amplify_analytics_pinpoint: '<1.0.0' the app runs on the simulator just fine. As soon as I put them back the errors return.
    • seanbrhn3
      seanbrhn3 over 3 years
      For the first error what fixed it for me was to go into the ios directory and in the Podfile change "platform ios:" To a higher deployment like 12 maybe. As for the second problem I'm currently having it too and not sure how to solve it.
  • Admin
    Admin over 3 years
    Okay I'm definitely confused now cause after making the changes you suggested, the same compiling for iOS 9.0, but module 'Starscream' error happened, but with @seanbrhn3 comment, I realized that if I changed the platform to iOS 12, the error returned has a minimum deployment target of iOS 12.0. The same thing with iOS 13 happened, so I tried with iOS 9, and it worked. Not sure why though, but I'll accept your answer for now, and if anything changes, I'll let you guys know. Thanks a lot, really helped.
  • Jameson
    Jameson over 3 years
    Please note that Amplify Flutter requires a minimum iOS target of 11.0. Refer: docs.amplify.aws/lib/auth/getting-started/q/platform/…
  • Bram
    Bram over 2 years
    It should not be under dev_dependencies