13

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.

Community
  • 1
  • 1
Ferran Maylinch
  • 10,919
  • 16
  • 85
  • 100
  • You are trying to run it on real device in debug or release mode ? – Slah Layouni Dec 29 '19 at 15:25
  • @SlahLayouni It was in Debug mode. I tried Release mode and it fails with the same error. – Ferran Maylinch Dec 29 '19 at 23:43
  • Try build release first then run it from xcode as release. `flutter build ios --release` – Slah Layouni Dec 29 '19 at 23:52
  • 1) Have you tried the iOS Simulator 2) Have you deployed/run a "Hello World" in Swift/Xcode to your iPhone device? Personal certificate should be good for deployment to your phone. – Morrison Chang Dec 29 '19 at 23:55
  • @SlahLayouni same error – Ferran Maylinch Dec 30 '19 at 00:04
  • @MorrisonChang Yes, the iOS simulator works fine. And now I just created and launched a "Hello World" Swift project in my iPhone. – Ferran Maylinch Dec 30 '19 at 00:05
  • And you've tried deleting the app manually from the iPhone and then `flutter run`. Also how long are you waiting for the app to launch on your phone? – Morrison Chang Dec 30 '19 at 00:11
  • @MorrisonChang Yes, after trusting the profile, the app installs and starts, but it crashes. Using `flutter run` I can't see the issue, but I suspect it's the same "code signature" error that I see in Xcode. I can wait forever, since the app basically crashed... :) I can see how the app opens (the screen is covered with a white view) and then immediately closes. – Ferran Maylinch Dec 30 '19 at 00:29
  • are your pods updated? – Yudhishthir Singh Jan 11 '20 at 20:32
  • 1
    can you check https://stackoverflow.com/a/58948346/7183675 and https://github.com/flutter/flutter/issues/16507#issuecomment-380790165 ? Interesting suggestions also here: https://github.com/flutter/flutter/issues/39962#issuecomment-532558471 and https://github.com/flutter/flutter/issues/41147#issuecomment-534783565 – Adam Tucholski Jan 16 '20 at 13:44
  • i have same problem as above. does it solved? @FerranMaylinch – sunita Feb 26 '20 at 19:10
  • @sunita not yet AFAIK :( see the response https://stackoverflow.com/a/60013390/1121497 – Ferran Maylinch Feb 27 '20 at 17:44

11 Answers11

11

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.

Jenn
  • 3,143
  • 1
  • 24
  • 28
  • Thank you very much! I hope this is fixed ASAP! – Ferran Maylinch Feb 01 '20 at 23:00
  • So this is on the iOS level issue? I am also encountering this issue on iPhone with iOS 13.3.1 version – Adro Feb 13 '20 at 06:01
  • Yes, this is a problem with iOS 13.3.1 and later rejecting Personal Team provisioning profile signed frameworks. It's not specific to Flutter. The links in the GitHub comment are referencing other projects, and I was easily able to reproduce with a brand new framework in Xcode without embedding Flutter. – Jenn Feb 14 '20 at 15:12
  • I just tried now with iOS 13.4 and it works! I could run my Flutter app on a real iPhone from Xcode and also from IntelliJ IDEA. I guess that it will work from the command line too. – Ferran Maylinch Mar 29 '20 at 20:49
  • Same thing happening to me on iOS 14 – T. Cervenka Nov 15 '20 at 16:50
4
  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.

Yudhishthir Singh
  • 2,941
  • 2
  • 23
  • 42
  • I have no Podfile. I'm looking at this post https://stackoverflow.com/questions/51599686/flutter-podfile-and-pods-folders-not-created-in-ios-directory – Ferran Maylinch Jan 15 '20 at 21:12
  • Install cocoapods to your machine and run the pod commands in your ios directory. – Yudhishthir Singh Jan 16 '20 at 03:27
  • I have made edits to my answer, please have a look. – Yudhishthir Singh Jan 16 '20 at 17:57
  • By the way, `pod install` says `[!] No 'Podfile' found in the project directory`, because Flutter doesn't generate a `Podfile`. Bug(?) explained [here](https://stackoverflow.com/questions/51599686/flutter-podfile-and-pods-folders-not-created-in-ios-directory). – Ferran Maylinch Jan 16 '20 at 22:29
  • About the Team: I already defined a Team. In fact, I can create a normal iOS app and run it on my iPhone, and for that I need a Team and a signature, and it works fine. But for Flutter something fails. – Ferran Maylinch Jan 16 '20 at 22:32
4

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.

nopassport1
  • 1,821
  • 1
  • 25
  • 53
Rookie
  • 41
  • 1
2

Can you follow step one by one

flutter channel master
flutter upgrade
flutter clean
flutter build ios
Dev
  • 6,628
  • 2
  • 25
  • 34
1

This post is not an answer because I am struggling with this issue as well and writing this since it's been a while without a fix

All I want is to provide more details to OP and other members here. So I have everything as OP stated.

This is what I have tried:

  1. Podfile is not created (even after running on Simulator and etc) and that is why I have tried including one from a flutter example app from Flutter Github.

    • Cleared iOS directory
    • Added a Podfile
    • Ran pod update.
    • Fixed warnings (provided Pod debug and release configurations to Xcode)
    • Added FLUTTER_ROOT to User-Defined settings (as was absent) and I was getting Xcode-backend.sh error (don't remember exactly, sorry)
    • Built

So these steps produce: this error on Simulator. Same signature errors as without Pod on physical device

  • Deleted all certificates from Keychain Access and restored them via Xcode.

    Result: Nothing changed

  • Removed Xcode, Pod and setting related to it. Removed certificates. Restored everything after a reboot (fresh installation)

    Result: Again, nor build with pod nor without provided the same errors

  • I have upgraded Flutter to the dev channel (1.14.1) and regenerated project using flutter create .

    Reran builds. With pods and without. Still same

  • Also I have tried to change signature from Apple Developer to iOS Developer on all target (Pod included)

    In this I have got some errors because I have even tried signing Pods-Runner (there was a little hope). But overall nothing new.

  • As I run a device on iOS 13.3.1 Beta, I upgraded Target to 13.2 (maximum available right now?).

    Nope

  • I have enable macOS-builds and built a Mac app

    It runs as indended, everything is alright.

To sum up:

  • This issue is not dependent on Pod/Non-Pod project.
  • Nothing changed regarding this issue between latest-stable flutter and latest dev (as post written)
  • This bug is not fixed by Xcode reinstallation and not related to Keychain certificates
  • Issue pops up only when building for only physical iOS Device (iPhone X in my case). Simulator (without Pod) runs well.

Btw. Everything was running on MacBook Pro 13 with Catalina 10.15.3 installed and Xcode 11.3.1.

Every Run was with -v flag and nothing suspicious was found in logs during build s

Again. I am sorry if I did something wrong posting this but I didn't want to duplicate this issue or suggest OP an edit as this post is pretty long.

Emin Guliev
  • 188
  • 2
  • 11
  • Thank you very much for this answer. It's not the solution but it's very helpful. Obviously, there's something wrong with Flutter. It looks like Google doesn't know exactly what Apple is expecting, or Apple is not interested in letting Flutter work smoothly... :) – Ferran Maylinch Jan 19 '20 at 09:33
  • By the way, yesterday I tried Flutter on another Mac, with Mojave (mine has Catalina), and I got the same error. – Ferran Maylinch Jan 19 '20 at 09:36
  • Most probably this is something related to CodeSign or Flutter itself. We should open an issue https://github.com/flutter/flutter/issues – Emin Guliev Jan 19 '20 at 11:24
  • Yes. Good idea. Let me know if you do it, or I can do it myself. – Ferran Maylinch Jan 19 '20 at 18:28
0

Try to switch to stable channel via flutter channel stable, execute flutter upgrade and then navigate to app project and run flutter run

Gioele Pannetto
  • 328
  • 3
  • 12
0

Just to run the app in Debug mode, doesn't need any apple paid account. 1) Open the xCode for that project and select the device and run in it.

Open the XCode of that project and check Build Settings as there is FLUTTER_ROOT path is correct, if not there create the flutter root and give the path.

Balaji Ks
  • 342
  • 3
  • 9
0

Open up the Xcode and click on Product -> Clean or (CMD-Shift-K). If that did not work try following this: https://macpaw.com/how-to/clear-xcode-cache

If that also not working, please let me know.

Blasanka
  • 21,001
  • 12
  • 102
  • 104
  • It doesn't work. I realised I have no Podfile, so I'm checking this: https://stackoverflow.com/questions/51599686/flutter-podfile-and-pods-folders-not-created-in-ios-directory – Ferran Maylinch Jan 15 '20 at 21:14
0

Did you check this link which might give you the desired output https://github.com/flutter/flutter/issues/16507. let me know if it works may be its a signing issue, this post will give you the idea whats going wrong. Thanks

Sagar Acharya
  • 3,397
  • 4
  • 12
  • 34
  • I have no Podfile so I'm checking this: https://stackoverflow.com/questions/51599686/flutter-podfile-and-pods-folders-not-created-in-ios-directory Anyway, I don't know what Podfile I need. I created one but I still get the same error. So maybe I don't need a Podfile or anyway the issue is another one. – Ferran Maylinch Jan 15 '20 at 21:15
0

Ok, having a moment to create answer:

Basing on Subaharan Vel answer, question: Flutter Podfile and Pods folders not created in ios directory and answer suggesting that building for iOS simulator can create podfile in incorrect place (it should be created automatically directly in iOS directory. So it seems likely that your Podfile exists somewhere there. Try to find it or just remove whole ios directory, clean the project and recreate it. Also make sure that this is not the case Creating a Podfile to add iOS pods before adding any Flutter plugins never hooks up the plugin pods in the existing Podfile.

Good luck, I hope it will help you

Adam Tucholski
  • 1,067
  • 11
  • 27
  • There is no `Podfile` anywhere. I run `find . -name Podfile` and I get nothing. I removed the `ios` directory but now, how can I recreate it? If I run `flutter build ios` I get the error `Application not configured for iOS`. – Ferran Maylinch Jan 18 '20 at 10:08
  • @Ferran Maylinch Just repeat all steps from Surbahan Vel (first link) - he did removed ios directory, and it was recreated after cleaning project. If necessary add podfile manually (from https://stackoverflow.com/a/53492243/7183675, remove unnecessary pods from there, also check second comment under this answer). As a last resort - it may help if you add at least one package to pubspec to force Flutter to create Podfile automatically. Even if this package isn't really in use – Adam Tucholski Jan 18 '20 at 11:32
0

Not an ideal solution but the following worked for me.

  1. Upgrade your device to iOS 13.4 beta.
  2. Perform a flutter run
  3. The build should be successful.
  4. It will throw "Your Xcode version may be too old for your iOS version" error.
  5. The application gets installed on the device. Note: The application will not launch automatically as the process terminates.
  6. Click on the installed app icon on your device to launch the app.

Although, you won't be able see anything on the debug window since the process terminates after throwing the error. It's not an ideal solution but definitely a workaround until we get the next Xcode update.