aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 242 forks source link

Module 'amplify_auth_cognito' not found #881

Closed Surya-thangavel closed 2 years ago

Surya-thangavel commented 3 years ago

Description: Build succeeds in Xcode run and also runs fine in Simulator, But When Archiving the runner

Error : "Parse Issue Module 'amplify_auth_cognito' not found"

Flutter doctor Output

`[✓] Flutter (Channel stable, 2.0.6, on macOS 11.5.2 20G95 darwin-x64, locale en-GB) • Flutter version 2.0.6 at /Users/srinivashvk/flutter • Framework revision 1d9032c7e1 (5 months ago), 2021-04-29 17:37:58 -0700 • Engine revision 05e680e202 • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/srinivashvk/Library/Android/sdk • Platform android-31, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1, Build version 12E507 • CocoaPods version 1.11.1

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.60.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.26.0

[✓] Connected device (2 available) • iPhone 11 (mobile) • A490CC7A-78F1-4A2F-9325-4E1047F49EB0 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator) • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63

• No issues found!`

Screenshot 2021-09-14 at 9 44 14 PM

Flutter build ios full log log (1).txt

dnys1 commented 3 years ago

Hi @Surya-thangavel can you please verify the deployment target of your app? This is a known issue when targeting older versions of iOS. Amplify requires this value to be iOS 11.0 or later (13.0 or later when using DataStore).

Screen Shot 2021-09-14 at 9 54 58 AM
Surya-thangavel commented 3 years ago

@dnys1 The targeting version is iOS 11.0 as I am not using DataStore.

fjnoyp commented 3 years ago

Hi @Surya-thangavel can you provide the logs file again as I cannot open it.

jsw-davidhuang commented 3 years ago

i think not only the main target version need to over ios11, but all other target in the xcodewordspace need to over ios11

benedict1986 commented 2 years ago

Hi @jsw-davidhuang , can you please elaborate a bit more? I am also having the same problem and all of my Deployment Targets are 13.0. Thank you.

Surya-thangavel commented 2 years ago

@fjnoyp Here's the log file flutter build ios log.txt

Surya-thangavel commented 2 years ago

@benedict1986 The app running on simulator and build succeed with amplify but only when archiving the app this error occurs, Is yours the same issue ?

jsw-davidhuang commented 2 years ago

Hi @jsw-davidhuang , can you please elaborate a bit more? I am also having the same problem and all of my Deployment Targets are 13.0. Thank you.

i think is something like this, this pod all need to be over ios 11 微信截图_20210917102228

fjnoyp commented 2 years ago

Hi @Surya-thangavel are you sure you are targeting 13.0? In the logs file provided I see the following messages at the end:

warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'FMDB' from project 'Pods')

fjnoyp commented 2 years ago

Thanks @jsw-davidhuang for your help clarifying how to set the main target version.

@Surya-thangavel @benedict1986 does following his advice help resolve your problem?

fjnoyp commented 2 years ago

Hi @Surya-thangavel I've been trying to reproduce your error but I am able to archive the amplify_auth_cognito example app no problem. Here is my setup:

Xcode 12.2

My Runner and Pods -> General tab -> Deployment Info are all set to iOS 11.0 as shown in the picture attached (just like jsw-davidhuang recommended)

In the logs you sent me, it appears you are still set to 8.0. I'm not able to target that version. What version of Xcode are you using?

Untitled
jsw-davidhuang commented 2 years ago

by the way, if still can not set to ios11, you should directly edit the .spec file in the pods folder, it is something like .symxxxx/packagename.podspec

benedict1986 commented 2 years ago

@benedict1986 The app running on simulator and build succeed with amplify but only when archiving the app this error occurs, Is yours the same issue ?

Hi @Surya-thangavel , I am not sure what do you mean by archiving. I can run my app in simulator but when I run it with my iPhone, I got this error.

Screen Shot 2021-09-18 at 11 16 55 pm

When I run flutter run in command line with my iPhone connected, I got the following error

Screen Shot 2021-09-18 at 11 37 48 pm
benedict1986 commented 2 years ago

Hi @jsw-davidhuang , can you please elaborate a bit more? I am also having the same problem and all of my Deployment Targets are 13.0. Thank you.

i think is something like this, this pod all need to be over ios 11 微信截图_20210917102228

Hi @jsw-davidhuang , I think I don't have this Pods project

Screen Shot 2021-09-18 at 11 12 16 pm
fjnoyp commented 2 years ago

@benedict1986 did you open the Runner.xcworkspace project? Your error message mentions that you should open that project. I think you might have opened the Runner.xcodeproj on accident instead.

benedict1986 commented 2 years ago

@benedict1986 did you open the Runner.xcworkspace project? Your error message mentions that you should open that project. I think you might have opened the Runner.xcodeproj on accident instead.

Hi @fjnoyp , after investigating a bit, I found the issue when I run flutter run is that I did not build in release mode. I added --release to the command and eventually got the following error, which was the same as what I got from Xcode.

Screen Shot 2021-09-21 at 12 02 58 am
benedict1986 commented 2 years ago

Hi @fjnoyp , I finally get my log as well but could not find any message similar as the one you pointed out for @Surya-thangavel.

Build target Runner_2021-09-21T00-48-54.txt

This is something about IPHONEOS_DEPLOYMENT_TARGET

Screen Shot 2021-09-21 at 12 57 14 am

Can you also please help to have a look and see if there is anything you can identify? Thanks a lot.

dnys1 commented 2 years ago

The following steps allow me to create a release archive. If someone can create a minimum set of steps to reproduce this issue, I will reopen. Otherwise, I believe this is resolved.

  1. Create a Flutter project and initialize Amplify with Auth category.
  2. Add amplify_flutter and amplify_auth_cognito as dependencies.
  3. Update Podfile to have platform :ios, '11.0'.
  4. Run pod install inside ios directory to generate Runner.xcworkspace.
  5. Open ios/Runner.xcworkspace and change deployment target to iOS 11.
  6. Run flutter build ios to create a release build.
  7. Open ios/Runner.xcworkspace and run Product > Archive.
benedict1986 commented 2 years ago

Hi @dnys1 , thank you for your step. My case is slightly different from yours. I already have Cognito setup in AWS and do not want to initialise Amplify with Auth category. I only want to use the library to use Cognito. Here is the minimum steps I am using to recreate the issue. Can you please let me know if there is any missing steps or anything wrong with it. I am happy to share myapp4 if you need it. Thank you.

  1. flutter create myapp4

    Screen Shot 2021-09-22 at 1 04 51 am
  2. add amplify_auth_cognito: ^0.2.4 to pubspec.yaml

    Screen Shot 2021-09-22 at 1 06 17 am
  3. run flutter pub get

    Screen Shot 2021-09-22 at 1 07 39 am
  4. double click Runner.xcworkspace in ios folder and open the project in Xcode

    Screen Shot 2021-09-22 at 1 08 29 am
  5. update iOS Deployment Target to 11.0

Screen Shot 2021-09-22 at 1 09 26 am
  1. Hook up IPHONE

  2. use personal team to sign the app, I changed the bundle identifier to com.example.myapp4-1024

    Screen Shot 2021-09-22 at 1 11 04 am
  3. make sure Runner > iPhone is selected

    Screen Shot 2021-09-22 at 1 12 19 am
  4. click the arrow to run the app

Screen Shot 2021-09-22 at 1 13 42 am
  1. run flutter build iOS
Screen Shot 2021-09-22 at 1 16 39 am
  1. Open Xcode -> Product. -> Archive Screen Shot 2021-09-22 at 1 18 52 am

=================================================== Here is the result of flutter doctor -v

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-AU) • Flutter version 2.2.3 at /Users/admin/Desktop/flutter • Framework revision f4abaa0735 (3 months ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4

[✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use flutter config --android-sdk to update to that location.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1, Build version 12E507 • CocoaPods version 1.11.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] Connected device (2 available) • iPhone (mobile) • 00008030-0003385122EA802E • ios • iOS 14.3 • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82

! Doctor found issues in 2 categories.

dnys1 commented 2 years ago

Hi @benedict1986, you are missing a couple steps. Please follow steps 3-4 from my post and try again.

jsw-davidhuang commented 2 years ago

Hi @benedict1986 i think when you build you got to better do like this:

1. flutter clean 
2. flutter build ios 
3. 3.open the xworkspace in the ios folder then build . 
4. but all this require the 0 step which is : you need to amplify init the project and input the keys you apply on aws cognito.
benedict1986 commented 2 years ago

Hi @dnys1 and @jsw-davidhuang , thank you for you advice.

According to @dnys1 , I ran pod init, update Podfile and pod install as follow

Screen Shot 2021-09-24 at 2 06 38 am Screen Shot 2021-09-24 at 2 10 32 am

Unfortunately, the error is still there. I trust your approach works. It means the only thing I did not try was to run amplify init with Auth category.

The reason I reluctant to run amplify init is because it provisions the backend in aws. It creates a new IAM user and something else. I don't know what exactly it's created so I want to use the existing aws profile (client id and client secret) instead of using amplify init to create another one.

Not sure if @Surya-thangavel has solved the problem or not.

Thanks for all of your help. Let me try to understand more about the library.

dnys1 commented 2 years ago

@benedict1986 Can you verify you are opening Runner.xcworkspace and not Runner.xcodeproj. The image above showed the latter.

Running amplify init is not technically required for building a release archive, so I don't believe that's the problem.

benedict1986 commented 2 years ago

Hi @dnys1, thank you for your advice. in the previous post with lots of images. I did not init and install pod. As a result there is no Pods project when I open Runner.xcworkspace. Now I init and install pod, I can see the Pods project when I open Runner.xcworkspace as follow

Screen Shot 2021-09-24 at 5 47 51 pm Screen Shot 2021-09-24 at 5 53 33 pm

In order to make sure I did not open a wrong file. I renamed the original Runner.xcworkspace to Runner2.xcworkspace and another Runner.xcworkspace is generated when I run pod install. And I pretty sure I opened the newly generated Runner.xcworkspace and then I see the Xcode as the image above.

Screen Shot 2021-09-24 at 5 49 45 pm

Unfortunately, even doing that, I still get the same error about amplify_auth_cognito module not found.

benedict1986 commented 2 years ago

Ok, finally, it's working...I summary the steps as follow:

  1. Run flutter create myapp
  2. Open pubspec.yaml and add amplify_auth_cognito: ^0.2.4
  3. Run flutter pub get. This step is what I am missing. After running this step, I saw the Podfile. Previously I did not run this step and create the Podfile with pod init, which is not right
  4. Update Podfile and uncomment platform :ios, '9.0' and update it to platform :ios, '11.0'
  5. Run pod install
  6. Open the newly generated Runner.xcworkspace
  7. Update the iOS Deployment target to 11.0. Refer to https://github.com/aws-amplify/amplify-flutter/issues/881#issuecomment-922274561
  8. Run flutter build ios to create a release build. I have a automatic signing issue in this step but I think it should be easy to resolve.
  9. I end up with running the app in Xcode and it can be build and successfully.

Massive thank to @fjnoyp and @dnys1

dnys1 commented 2 years ago

Thank you for the update @benedict1986. I'm glad you were able to get it resolved 👍

richard457 commented 1 month ago

This is happening to me on macos flutter 3.24 and latest amplify_auth_cognito