Nadezhda
Nadezhda

Reputation: 23

Flutter iOS App Crashes on Launch from Device Icon, but Runs Fine from Xcode

I'm encountering an issue with my Flutter iOS app where, after installing it on a real device (iPhone 13), it runs successfully upon the initial installation using Xcode. However, if I close the app and try to reopen it by tapping on the app icon on the device, it crashes immediately. This behavior is not observed on an older iPhone 6+ running iOS 12, and the app also works fine in the simulator. Even a simple Flutter test template crashes when launched from the device icon, working only when initiated through Xcode's "Run" button.

Upvotes: 2

Views: 964

Answers (4)

Nur_iOS
Nur_iOS

Reputation: 81

This is expected behavior when running the app in debug mode. Here's what's happening:

1. When running through Xcode/Android Studio in debug mode:

  • The app works because it's connected to the debug session
  • Once you terminate the debug session and try to launch from the app icon, it crashes because the debug session is required

Solution: 1. Run the app in Profile or Release mode instead:

  • In Android Studio: Select 'Profile' or 'Release' from the run configurations dropdown
  • Select to your main.dart file
  • Run the app

2. After installing in Profile/Release mode:

  • The app will work normally when launched from the app icon
  • You can terminate and relaunch without crashes

This is not a bug but rather the expected behavior of debug builds, which are not meant for standalone operation outside of the development environment.

Upvotes: 0

Zigglzworth
Zigglzworth

Reputation: 6813

When running your flutter app to a device via xcode (assuming you have completed all the xcode setup, certificates, etc), you should use the following command from your flutter project directory:

flutter run --profile -d 'YOUR_DEVICE'

(Use 'flutter devices' if you need to see the connected devices)

Upvotes: 1

Justin_Lee
Justin_Lee

Reputation: 1

"To launch in debug mode in iOS 14+, run flutter run from Flutter tools, run from an IDE with a Flutter IDE plugin or run the iOS project from Xcode. Alternatively profile and release mode apps can be launched from the home screen." github issues

Upvotes: 0

Sayid
Sayid

Reputation: 443

You need to run the application on the profile mod.

Upvotes: -1

Related Questions