How to correctly implement Amplify to Flutter
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
Admin
Updated on December 27, 2022Comments
-
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
andTarget of URI doesn't exist: 'package:amplify_core/amplify_core.dart'
Things I tried:
-
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
andCommand 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 lineplatform :ios, '9.0'
on Podfile and changed it toplatform :ios, '11.0'
, while also changing the development target to 11 on the projects xcworkspace. The same error happened. -
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. -
Restarting the computer.
-
Deleting the Amplify folder.
-
Running
amplify uninstall
, and trying from the start again. -
Searching other posts on this and other websites.
-
Running
amplify clean
.
Things to note:
- The Amplify installation, init, and configure steps returned no errors.
- 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 over 3 yearsFor 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 over 3 yearsOkay 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 returnedhas 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 over 3 yearsPlease note that Amplify Flutter requires a minimum iOS target of 11.0. Refer: docs.amplify.aws/lib/auth/getting-started/q/platform/…
-
Bram over 2 yearsIt should not be under dev_dependencies