Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Run not working, Error launching application on iPhone

I have updated the flutter version recently. after that flutter run is not working on iPhone. I am using android studio. run button on the android studio also not working for iPhone but simulators are working fine.

I am getting the following error. I have set the runner schema to release. still no luck.

"Error launching application on Raj iPhone."

enter image description here

Flutter version.

Flutter (Channel master, 1.24.0-8.0.pre.374, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB)

I am not getting any additional errors. so i run flutter run -verbose i got the following info

#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:618:7) #2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1119:12) #3 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:974:27) #4 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #5 AppContext.run (package:flutter_tools/src/base/context.dart:149:12) #6 CommandRunner.runCommand (package:args/command_runner.dart:197:13) #7 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:264:9) #8 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #9 AppContext.run (package:flutter_tools/src/base/context.dart:149:12) #10 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:220:5) #11 run.. (package:flutter_tools/runner.dart:63:9) #12 run. (package:flutter_tools/runner.dart:61:12) #13 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #14 AppContext.run (package:flutter_tools/src/base/context.dart:149:12) #15 runInContext (package:flutter_tools/src/context_runner.dart:70:10) #16 main (package:flutter_tools/executable.dart:90:3)

        [ +113 ms] (lldb) process detach [ +254 ms] ensureAnalyticsSent: 255ms [   +1 ms] Running shutdown hooks [       

] Shutdown hook priority 4 [ +52 ms] Shutdown hooks complete [
] exiting with code 1

I have done flutter clean and checked again. still same issue.

Thanks

like image 771
Soundhar Raj Avatar asked Dec 01 '20 11:12

Soundhar Raj


People also ask

How do I run the Flutter app on my Iphone physically?

To test or deploy our flutter app to a physical device we first need to enable physical device deployment in Xcode using Apple ID or an Apple Developer account. And we also need to set up a package manager to manage flutter plugins that are to be used in the project.

How does Flutter run the code on iOS?

How does Flutter run my code on iOS? The engine's C and C++ code are compiled with LLVM. The Dart code (both the SDK's and yours) are ahead-of-time (AOT) compiled into a native, ARM library. That library is included in a “runner” iOS project, and the whole thing is built into an .

Can I run Flutter on Iphone from Windows?

Flutter is a multi-platform application development framework that enables you, among other platforms, to develop iOS and Android apps from the same source code. However, you need to use Xcode to build an iOS app and Xcode will only work on macOS. You cannot get away with Linux or Windows.


Video Answer


1 Answers

In flutter/packages/flutter_tools/lib/src/ios/devices.dart, find the following code block:

_logger.printTrace('Application launched on the device. Waiting for observatory port.');
Uri localUri;
try {
  localUri = await observatoryDiscovery.uri.timeout(const Duration(seconds: 30));
} on TimeoutException {
  await observatoryDiscovery.cancel();
}

Increase the timeout to a bigger number, for example, 60 seconds fixed it for me:

localUri = await observatoryDiscovery.uri.timeout(const Duration(seconds: 60));

enter image description here

Also, remove the cached binaries to force snapshot regeneration:

rm /{$PATH_TO_FLUTTER_DIRECTORY}/bin/cache/flutter_tools.stamp /{$PATH_TO_FLUTTER_DIRECTORY}/bin/cache/flutter_tools.snapshot

References:

  • https://github.com/flutter/flutter/issues/72161

  • https://github.com/flutter/flutter/blob/a603714610f8c9c831e7d85071274460d70c18da/packages/flutter_tools/lib/src/ios/devices.dart#L432

  • https://github.com/flutter/flutter/tree/master/packages/flutter_tools#forcing-snapshot-regeneration

like image 88
davejlin Avatar answered Oct 16 '22 21:10

davejlin