Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter signature invalid when tried on an iOS device

Tags:

ios

flutter

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.

like image 856
Ferran Maylinch Avatar asked Dec 29 '19 15:12

Ferran Maylinch


People also ask

How do I connect my iOS device to Flutter?

You need to go to your Settings > General > Device Management. Inside Device Management, select the developer name and tap Trust “YOUR DEVELOPER NAME”. You should now be able to run your Flutter app on your local device.

Is Flutter compatible with iOS?

Flutter supports iOS 9.0 and later. If your app or plugins include Objective-C or Swift code that makes use of APIs newer than iOS 9, update this setting to the highest required version.

Does Flutter support iOS 14?

We're delighted to introduce our latest release of Flutter, with extensive support for iOS 14 and Android 11.


Video Answer


4 Answers

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.

like image 167
Jenn Avatar answered Oct 17 '22 22:10

Jenn


  1. Did you agree to xcode license agreement? if not, try sudo xcodebuild -license.
  2. Are your pods updated? if not, navigate to ios folder in the flutter project in your terminal and type pod install then pod update

If this doesn't work, go to the ios folder in your flutter project and open Runner.xcworkspace by double-tapping on it. It should look like this:

enter image description here

When xcode opens, click on Runner on the top left.

enter image description here

Then go to Signing and Capabilities and under the "Team" dropdown, select a field. If none exists, create an account.

enter image description here

Then in the "Bundle Identifier", your app's bundle name should be showing. Add .app in the end. For example, if its "com.example.yourapp" make it "com.example.yourapp.app" and press enter.

Press the play button on top left to run the app on selected device.

like image 22
Yudhishthir Singh Avatar answered Oct 17 '22 21:10

Yudhishthir Singh


As far as I can see it's a Flutter compatibility issue with iOS 13.3.1. In my case, my app runs perfectly fine on iPhone XR with iOS 13.3 but crashes on launch on another iPhone XR with iOS 13.3.1. Can not test in simulator as it's a camera app but it does work on both physical Android devices and Android emulators.

like image 4
Rookie Avatar answered Oct 17 '22 23:10

Rookie


Can you follow step one by one

flutter channel master
flutter upgrade
flutter clean
flutter build ios
like image 2
Dev Avatar answered Oct 17 '22 22:10

Dev