Flutter, no such module ‘Firebase’ when construction on ios


As this is a flutter error, I wish to find a clean fix from my terminal without going into xcode configurations

the list of commands below used to get it done for me before i upgraded flutter to 3.13.4

List of commands that I used before building or running a new clean build after updating my code

    delete ios/Pods
    delete ios/Podfile.lock
    delete pubspec.lock
    flutter clean
    flutter pub get
    pod deintegrate
    pod repo remove trunk
    sudo gem install cocoapods-deintegrate cocoapods-clean
    pod cache clean --all
    sudo gem uninstall cocoapods
    sudo gem install cocoapods
    pod setup
    pod install --verbose
    pod update --verbose
    flutter build ios-framework --output=Flutter
    
and as well i did not forget to restart xcode & intellij idea, and i refuse the notion that restarting my mac might fix it.


My flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.4, on macOS 13.0 22A380 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Community Edition (version 2023.1.2)
[✓] Connected device (3 available)
[✓] Network resources

my AppDelegate.swift (this used to work perfectly)

import UIKit
import Flutter
import Firebase
import FirebaseMessaging

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

    Messaging.messaging().apnsToken = deviceToken
    print("Token: \(deviceToken)")
    super.application(application,
    didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
  }
}

This is my Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

source 'https://github.com/CocoaPods/Specs.git'
# source 'https://cdn.cocoapods.org/'
# source 'https://cocoapods-cdn.netlify.app/'

# 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__))
  pod 'GoogleUtilities'
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['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
            '$(inherited)',
            'PERMISSION_MICROPHONE=1',
            'PERMISSION_CAMERA=1',
            'PERMISSION_PHOTOS=1',
            'PERMISSION_LOCATION=1',
            'PERMISSION_NOTIFICATIONS=1',
      ]
      if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
        target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
          config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
      end
    end
  end
end

target 'ImageNotification' do
  use_frameworks!
  pod 'Firebase/Messaging'
  pod 'GoogleUtilities'
end

and now it’s failing to build throwing :-

[   +2 ms] Swift Compiler Error (Xcode): Using bridging headers with module interfaces is unsupported
           
[   +1 ms] Uncategorized (Xcode): Command SwiftDriver emitted errors but did not return a nonzero exit code to indicate failure
           
[        ] Error (Xcode): no such module 'Firebase'
           /Users/rageh/Library/Developer/Xcode/DerivedData/Runner-ermxlolpdlimwigajulthlreyixv/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner.swiftinterface:4:7
           
[        ] Error (Xcode): no such module 'Firebase'
           /Users/rageh/Library/Developer/Xcode/DerivedData/Runner-ermxlolpdlimwigajulthlreyixv/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner.private.swiftinterface:4:7
           
[        ] Error (Xcode): failed to verify module interface of 'Runner' due to the errors above; the textual interface may be broken by project issues or a compiler bug
           /Users/rageh/Library/Developer/Xcode/DerivedData/Runner-ermxlolpdlimwigajulthlreyixv/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner.private.swiftinterface:0:0
           
[   +1 ms] Could not build the application for the simulator.
[        ] Error launching application on iPhone 14 Pro Max.
[   +2 ms] "flutter run" took 1,230,760ms.
[  +17 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:760:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1297:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:339:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:285:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:115:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:90:3)
           <asynchronous suspension>

Leave a Reply

Your email address will not be published. Required fields are marked *