Flutter signature invalid when tried on an iOS device

Question

Asked by Ferran M on December 29, 2019 (source).

TL;DR

EDIT 2020-05-06 : My app installs correctly from iOS 13.4, but after some time the app crashes at start and I have to re-install it. I don't know why. Maybe after iOS updates?

Also see answer below: https://stackoverflow.com/a/60013390/1121497

Full question

I am trying to run a new Flutter app (the sample app created by flutter create) on an iOS device (an iPhone XS). Xcode manages to install it, but then it crashes with this message:

dyld: Library not loaded: @rpath/Flutter.framework/Flutter
  Referenced from: /private/var/containers/Bundle/Application/BA807438-FA5B-4021-B37D-FC437B2C80CA/Runner.app/Runner
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/BA807438-FA5B-4021-B37D-FC437B2C80CA/Runner.app/Frameworks/Flutter.framework/Flutter: code signature invalid for '/private/var/containers/Bundle/Application/BA807438-FA5B-4021-B37D-FC437B2C80CA/Runner.app/Frameworks/Flutter.framework/Flutter'

If I try flutter run, the app also opens and crashes. And the command keeps waiting forever:

$ flutter run
Launching lib/main.dart on Ferran Maylinch’s iPhone in debug mode...
 
Automatically signing iOS for device deployment using specified development team in Xcode project: 25D86TPBWG
Running Xcode build...                                                  
                                                   
 ├─Assembling Flutter resources...                           4.3s
 └─Compiling, linking and signing...                        13.3s
Xcode build done.                                           21.0s
Installing and launching...                                             
(This is taking an unexpectedly long time.)       ⢿

In Xcode I configured a Team (Personal Team) and the Signing Certificate (Apple Development certificate) seems fine because I can install a Hello world Swift project on my device.

Note: I'm not paying an account of Apple Developer Program. Is that absolutely necessary to run Flutter apps on iOS devices?

I have followed the macOS instructions and flutter doctor says I have everything I need for iOS:

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-ES)
 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[!] Android Studio (version 3.5)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
[!] VS Code (version 1.41.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)

! Doctor found issues in 3 categories.

As you can see, I used the stable channel, to discard problems with the beta channel, but I usually work in the beta channel to build flutter for web (which works fine).

In the iOS simulator the app works fine too.

Recently I noticed that I don't have the file ios/Podfile. I found this post talking about that. I don't know whether this is important or not in my case, but I tried to manually add this Podfile. Anyway, I get the same signature error.

Frustrated by this, I switched to NativeScript for now.

Answer

Question answered by Jenn (source).

EDIT: This is fixed on iOS 13.4, which was released March 24.

This is an iOS 13.3.1 regression unrelated to Flutter. I was able to reproduce the crash without any Flutter or CocoaPods code by creating a new Xcode project, adding a framework target, and choosing a Personal Team provisioning profile.

See GitHub issue: https://github.com/flutter/flutter/issues/49504#issuecomment-581554697.

The bug should not impact Developer Account team provisioning profiles or apps that are already signed and distributed on the App Store.

Unfortunately the only workaround may be to avoid upgrading development devices to 13.3.1 until this is resolved.

FLUTTER IOS
SHARE: