10

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

3
  • 2
    Have you opened the project through xcode and registered your iphone? Try to compile at least once directly from xcode to the iphone. Commented Dec 1, 2020 at 12:41
  • until i upgrade the flutter. it was working fine. my iphone id was added to the developer profile. its not the first time i run this project. i was working on it for a month. after the upgrade it stops working Commented Dec 1, 2020 at 15:59
  • 1
    now, i tried to run from xcode workspace. its running fine. only issue is flutter run on device failed :( Commented Dec 1, 2020 at 16:09

2 Answers 2

5

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:

Sign up to request clarification or add additional context in comments.

2 Comments

In addition to this, you'll also need to force snapshot regeneration of flutter_tools, otherwise the changes you make to the dart code won't be applied. To do this you can run rm /{$PATH_TO_FLUTTER_DIRECTORY}/bin/cache/flutter_tools.stamp /{$PATH_TO_FLUTTER_DIRECTORY}/bin/cache/flutter_tools.snapshot. Source: github.com/flutter/flutter/tree/master/packages/…
Thanks @brianbhsu - I added your helpful comment to the answer.
0
Delete or Clear directory ~/Library/Develope/Xcode/iOS\ DeviceSupport/ is not recommended.

In my case, that is the flutter sdk bundled command ios-deploy (version 1.11.2-beta.1) issue. It find the wrong path of ~/Library/Developer/Xcode/iOS\ DeviceSupport/[iOS_Version_ARCH]/Symbols.

  1. First check your ios-deploy version: __PATH_TO_YOUR_Flutter_SDK_/bin/cache/artifacts/ios-deploy/ios-deploy --version

  2. Replace it with to current newest version 1.12.1.

    git clone https://github.com/ios-control/ios-deploy.git
    cd ios-deploy/ 
    git checkout 1.12.1
    
    ## build it 
    xcodebuild -project ios-deploy.xcodeproj -list
    xcodebuild -project ios-deploy.xcodeproj -scheme ios-deploy
    
    ## get the built output path
    xcodebuild -project ios-deploy.xcodeproj -scheme ios-deploy -showBuildSettings | grep BUILD_DIR  
    
    ## or use Xcode to build
    open ios-deploy.xcodeproj  ## Build project with key: ⌘ + B
    
    ## check the output file
    ~/Library/Developer/Xcode/DerivedData/ios-deploy-[xxxxx]/Build/Products/Debug/ios-deploy  --version 
    
    ## replace the one in flutter sdk
    cp ~/Library/Developer/Xcode/DerivedData/ios-deploy-[xxxxx]/Build/Products/Debug/ios-deploy __PATH_TO_YOUR_Flutter_SDK_/bin/cache/artifacts/ios-deploy/
    
    
    
  3. Run your flutter project again with Android studio or Visual Studio Code or flutter run again. Finally succeeded.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.