Flutter build for IOS: Module 'amplify_auth_cognito' not found

72 Views Asked by At

I'm using Flutter and AWS Auth Cognito, when i try to run flutter run on an ios simulator i get the follwowing error message:

leon@MBP app % flutter run --flavor dev
Launching lib/main.dart on iPhone 15 Pro in debug mode...
Running Xcode build...                                                  
 └─Compiling, linking and signing...                      1,531ms
Xcode build done.                                           11.0s
Failed to build iOS app
Parse Issue (Xcode): Module 'amplify_auth_cognito' not found
/Users/leon/work/app/ios/Runner/GeneratedPluginRegistrant.m:11:8


Could not build the application for the simulator.
Error launching application on iPhone 15 Pro. 

However, if i start it via. XCode i can build the app on the simulator without any issues. On an Android emulator it works as well via the run command or the vs-code run options provided in my launch.json.

Flutter doctor:

✓] Flutter (Channel stable, 3.13.8, on macOS 14.3.1 23D60 darwin-arm64, locale en-DE)
    • Flutter version 3.13.8 on channel stable at /opt/homebrew/Caskroom/flutter/3.3.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6c4930c4ac (4 months ago), 2023-10-18 10:57:55 -0500
    • Engine revision 767d8c75e8
    • Dart version 3.1.4
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/me/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.13.0

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

[✓] Android Studio (version 2021.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.13+0-b1751.21-8125866)

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

[✓] Connected device (3 available)
    • iPhone 15 Pro (mobile) • 8D18B1DA-DB2D-47CA-9D0D-2EBCDC7784E3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 121.0.6167.184

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '15.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('../','Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end

source 'https://cdn.cocoapods.org/'

Pubspec.yaml:

name: app
description: A new Flutter project.

publish_to: "none" # Remove this line if you wish to publish to pub.dev

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.18.0 <4.0.0"
  flutter: ">=3.3.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.5
  smooth_page_indicator: ^1.0.0+2

  # i18n section
  flutter_localizations:
    sdk: flutter
  intl: ^0.18.0 # flutter_localizations


  flutter_riverpod: ^2.3.6
  hooks_riverpod: ^2.3.6
  flutter_hooks: ^0.18.6
  path: ^1.8.1
  shared_preferences: ^2.0.15

  # Charts
  # TODO: Replace with fl_charts. High priority, since syncfusion_flutter_gauges
  # has the problem with memory leaks
  # Reference: https://github.com/syncfusion/flutter-examples/issues/67
  syncfusion_flutter_gauges: ^21.2.4

  phosphor_flutter: ^2.0.0
  flutter_svg: ^2.0.7

  amplify_flutter: ^1.0.0
  amplify_auth_cognito: ^1.6.2
  amplify_authenticator: ^1.0.0

  freezed_annotation: ^2.0.3
  json_annotation: ^4.8.1
  jiffy: ^5.0.0
  dotted_line: ^3.1.0
  go_router: ^7.0.1
  package_info_plus: ^4.0.2

  http: ^0.13.5
  dio: ^5.3.0

  month_picker_dialog: ^2.0.0
  auto_size_text: ^3.0.0
  url_launcher: ^6.2.2
  graphql: ^5.1.2
  graphql_flutter: ^5.1.1
  upgrader: ^6.5.0

  # Sentry
  sentry_flutter: ^7.13.1
  sentry_logging: ^7.13.1
  sentry_dio: ^7.13.1
  logging: ^1.2.0

  flutter_secure_storage: ^9.0.0
  local_auth: ^2.1.7
  local_auth_ios: ^1.1.4
  local_auth_android: ^1.0.35
  flutter_flavorizr: ^2.2.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  faker: ^2.0.0
  flutter_lints: ^2.0.1
  mocktail: ^0.3.0
  collection: ^1.16.0
  build_runner: ^2.4.4
  freezed: ^2.0.4
  json_serializable: ^6.7.0
  integration_test:
    sdk: flutter
  flutter_driver:
    sdk: flutter
  test: ^1.24.3



# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # Related to i18n section in dependencies
  generate: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/Graphics/
    - assets/Graphics/onboarding/
    - assets/Graphics/logo/
    - assets/Graphics/Cards/
    - assets/Graphics/tva/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Inter
      fonts:
        - asset: assets/google-fonts/Inter/static/Inter-Bold.ttf
          weight: 700
        - asset: assets/google-fonts/Inter/static/Inter-SemiBold.ttf
          weight: 600
        - asset: assets/google-fonts/Inter/static/Inter-Regular.ttf
          weight: 400

    # - family: <Name>
    #   fonts:
    #     - asset: <path>.ttf
    #       style: normal
#           weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

I already updated the auth_cogntio plugin, updated the pod repo, deintegrated the pod, installed the pod again and so on. I think it's an configuration issue but I don't know where else to look since it runs via the XCode run but fails everywhere else.

I'd expect it to run via the vsCode run, or terminal as well as building it via the ./ios/Runner.xcworkspace UI

Maybe someone else faced the same issue?

0

There are 0 best solutions below