Skip to content

flutter run does not show logs on iOS #127121

Closed

Description

@eseidel

Is there an existing issue for this?

Steps to reproduce

void main() {
  print("Log from dart");
  runApp(const MyApp());
}
flutter run -d iphone

Expected results

Should show logs.

Actual results

Doesn't show logs.

Code sample

Code sample
void main() {
  print("Log from dart");
  runApp(const MyApp());
}

Screenshots or Video

No response

Logs

Logs

No logs from terminal:

eseidel@erics-mbp ios_test % flutter run -d iphone      
Launching lib/main.dart on iPhone in Pocket in debug mode...
Automatically signing iOS for device deployment using specified development team
in Xcode project: 8R83HS5GZ2
Running Xcode build...                                                  
 └─Compiling, linking and signing...                      1,879ms
Xcode build done.                                            5.8s
(lldb) 2023-05-18 10:04:50.359884-0700 Runner[1136:55318] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
flutter: Log from dart
Installing and launching...                                        11.0s
Syncing files to device iPhone in Pocket...                         29ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on iPhone in Pocket is available at:
http://127.0.0.1:55530/RoespouBheY=/
The Flutter DevTools debugger and profiler on iPhone in Pocket is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:55530/RoespouBheY=/

They show up in XCode fine:

2023-05-18 09:51:27.536411-0700 Runner[1037:45700] Metal API Validation Enabled
2023-05-18 09:51:27.708781-0700 Runner[1037:45700] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
2023-05-18 09:51:27.760726-0700 Runner[1037:46008] flutter: The Dart VM service is listening on http://127.0.0.1:60534/ZpThp0psw04=/
2023-05-18 09:51:27.818336-0700 Runner[1037:45988] flutter: Log from dart

Flutter Doctor output

Doctor output
eseidel@erics-mbp ios_test % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.2.1 22D68 darwin-arm64, locale
    en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.78.2)
[✓] Connected device (3 available)
    ! Error: Eric’s Apple Watch has recently restarted. To use Eric’s
      Apple Watch with Xcode, unlock it and its companion iPhone (code 19)
[✓] Network resources

• No issues found!
eseidel@erics-mbp ios_test %  flutter devices
3 connected devices:

iPhone in Pocket (mobile) • 00008120-0011315A2290C01E • ios            • iOS
16.4.1 20E252

Activity

  1. eseidel commented on May 18, 2023

    @eseidel
    ContributorAuthor

    If I add a log to _incrementCounter() those show up:

      void _incrementCounter() {
        setState(() {
          print("incrementing counter");
          // This call to setState tells the Flutter framework that something has
          // changed in this State, which causes it to rerun the build method below
          // so that the display can reflect the updated values. If we changed
          // _counter without calling setState(), then the build method would not be
          // called again, and so nothing would appear to happen.
          _counter++;
        });
      }
    flutter: incrementing counter
    flutter: incrementing counter
    flutter: incrementing counter
    flutter: incrementing counter
    flutter: incrementing counter
    flutter: incrementing counter
    flutter: incrementing counter
    flutter: incrementing counter
  2. added
    platform-iosiOS applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    on May 18, 2023
  3. zanderso commented on May 18, 2023

    @zanderso
    Member

    cc @vashworth @christopherfujino Guessing that prints near app startup might be getting dropped if the debugger isn't attached yet?

  4. christopherfujino commented on May 18, 2023

    @christopherfujino
    Contributor

    @vashworth do we not start the main isolate paused until the debugger attaches?

  5. vashworth commented on May 18, 2023

    @vashworth
    Contributor

    @vashworth do we not start the main isolate paused until the debugger attaches?

    Looks like we do not start it paused (assuming that's what this flag is for).

    bool get startPausedDefault => false;

    ..addFlag('start-paused',
    defaultsTo: startPausedDefault,
    help: 'Start in a paused mode and wait for a debugger to connect.',
    )

  6. christopherfujino commented on May 18, 2023

    @christopherfujino
    Contributor

    ahhh

  7. jason-simmons commented on May 18, 2023

    @jason-simmons
    Member

    The flutter: Log from dart log message is shown in the tool's output (as seen in the logs captured in #127121 (comment))

    But the log message is printed midway through the Installing and launching phase, so it's easy to miss.

    The flutter_tools iOS device could buffer the debugger log stream until the tool has finished launching the app and printing the tool usage instructions. But that might hide potentially useful logs if something goes wrong during the tool's app launch flow.

  8. christopherfujino commented on May 18, 2023

    @christopherfujino
    Contributor

    The flutter: Log from dart log message is shown in the tool's output (as seen in the logs captured in #127121 (comment))

    But the log message is printed midway through the Installing and launching phase, so it's easy to miss.

    The flutter_tools iOS device could buffer the debugger log stream until the tool has finished launching the app and printing the tool usage instructions. But that might hide potentially useful logs if something goes wrong during the tool's app launch flow.

    wow, eagle eye

  9. eseidel commented on May 18, 2023

    @eseidel
    ContributorAuthor
  10. eseidel commented on May 25, 2023

    @eseidel
    ContributorAuthor

    I think we closed this prematurely? Unless I misunderstood. When I add a log in the engine, from within xcode I get:

    flutter build ios --config-only --local-engine-src-path=$HOME/Documents/GitHub/ios_engine/src --local-engine ios_debug_unopt_arm64

    2023-05-25 14:43:17.095278-0700 Runner[35905:3750023] [VERBOSE0:FlutterViewController.mm(232)] sharedSetupWithProject
    2023-05-25 14:43:17.095494-0700 Runner[35905:3750023] Metal API Validation Enabled
    2023-05-25 14:43:17.273696-0700 Runner[35905:3750023] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.
    2023-05-25 14:43:17.329845-0700 Runner[35905:3750345] flutter: The Dart VM service is listening on http://127.0.0.1:56867/OTrtAg28Ux8=/
    2023-05-25 14:43:17.409185-0700 Runner[35905:3750321] flutter: Log from dart
    

    But from flutter run I get:

    eseidel@erics-mbp ios_test % flutter run -d iphone --local-engine-src-path=$HOME/Documents/GitHub/ios_engine/src --local-engine ios_debug_unopt_arm64
    Launching lib/main.dart on iPhone in Pocket in debug mode...
    Automatically signing iOS for device deployment using specified development team in Xcode
    project: 8R83HS5GZ2
    Running Xcode build...                                                  
     └─Compiling, linking and signing...                      2,256ms
    Xcode build done.                                            9.3s
    Installing and launching...                                        18.5s
    Syncing files to device iPhone in Pocket...                         46ms
    
    Flutter run key commands.
    r Hot reload. 🔥🔥🔥
    R Hot restart.
    h List all available interactive commands.
    d Detach (terminate "flutter run" but leave application running).
    c Clear the screen
    q Quit (terminate the application on the device).
    
    A Dart VM Service on iPhone in Pocket is available at: http://127.0.0.1:62201/H4-c8GRdgCA=/
    The Flutter DevTools debugger and profiler on iPhone in Pocket is available at:
    http://127.0.0.1:9101?uri=http://127.0.0.1:62201/H4-c8GRdgCA=/
    

    This is with:

    eseidel@erics-mbp ios_test % flutter --version
    Flutter 3.11.0-14.0.pre.15 • channel main • https://github.com/flutter/flutter.git
    Framework • revision 8576da53c5 (45 minutes ago) • 2023-05-25 14:01:18 -0700
    Engine • revision 6ff02c1726
    Tools • Dart 3.1.0 (build 3.1.0-146.0.dev) • DevTools 2.23.1
    

    And then flutter-team-archive/engine@6ff02c1, with a slightly modified dart_lang/sdk of the correct version.

  11. eseidel commented on May 25, 2023

    @eseidel
    ContributorAuthor

    For clarity, the log I added was:

    2023-05-25 14:43:17.095278-0700 Runner[35905:3750023] [VERBOSE0:FlutterViewController.mm(232)] sharedSetupWithProject
    

    Maybe I have to turn up the verbosity to see the log?

  12. eseidel commented on May 25, 2023

    @eseidel
    ContributorAuthor

    Yup, I see the log when I turn on -v. OK.

  13. github-actions commented on Jun 8, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform-iosiOS applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions