flutter_downloader: XCode archive error 'No such module flutter_downloader' when using AppDelegate.swift

I can’t archive the project with XCode if I use AppDelegate.swift as stated in the docs. Both flutter run --release and flutter build ios work.

  • XCode: Version 11.3.1 (11C504)

  • AppDelegate.swift:

import UIKit
import Flutter
import flutter_downloader

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

private func registerPlugins(registry: FlutterPluginRegistry) {
    if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
       FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin"))
    }
}
  • flutter doctor -v:
[✓] Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.1 19B88, locale pt-BR)
    • Flutter version 1.12.13+hotfix.7 at /Users/JHBitencourt/Documents/
    • Framework revision 9f5ff2306b (8 weeks ago), 2020-01-26 22:38:26 -0800
    • Engine revision a67792536c
    • Dart version 2.7.0
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/JHBitencourt/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.0.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
  • Error:

image_error

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 21 (2 by maintainers)

Most upvoted comments

Open xcworkspace instead of xcodeproj and it will work fine

None of the above solutions worked for me so this is how I solved mine:

  1. Run flutter clean
  2. Open the project folder navigate to ios directory and delete the ‘Pods’ folder
  3. Open terminal and navigate to ios directory in your project folder and run pod install
  4. When done, open ‘Runner.xcworkspace’
  5. In Xcode, clean the build folder by going to Product > Clean Build Folder
  6. Build the project (Product > Build) and everything should work fine.

I’m closing this issue since the problem wasn’t this plugin. Some flavor and runner configurations got messed up, but now everything works fine.

@tronghuy5555 @batteryfull as I said my problem was because I have custom schemes, and my prod scheme was pointing to the build configuration of other one in the archive phase.

image

So neither changing target to iOS 9.0 or recreating ios project would work. And this last one is not indicated if you have custom configurations.

I’m closing this issue since the problem wasn’t this plugin. Some flavor and runner configurations got messed up, but now everything works fine.

Hi @JHBitencourt , how do you fix that? Could you show the code?