1. 12 Dec, 2023 1 commit
    • Christopher Fujino's avatar
      [flutter_tools] catch SocketException writing to ios-deploy stdin (#139784) · fac41dde
      Christopher Fujino authored
      Fixes https://github.com/flutter/flutter/issues/139709
      
      This adds a static helper method `ProcessUtils.writelnToStdinGuarded()`, which will asynchronously write to a sub-process's STDIN `IOSink` and catch errors.
      
      In talking with Brian, it sounds like this is the best and most reliable way to catch `SocketException`s during these writes *to sub-process file descriptors* specifically (with a "real" hard drive file, the future returned by `.flush()` should complete with the write error).
      
      Also, as I note in the dartdoc to `writelnToStdinGuarded()`, the behavior seems to be different between macOS and linux.
      
      Moving forward, in any place where we want to catch exceptions writing to STDIN, we will want to use this new helper.
      fac41dde
  2. 08 Dec, 2023 1 commit
  3. 04 Dec, 2023 1 commit
  4. 30 Nov, 2023 1 commit
  5. 29 Nov, 2023 1 commit
  6. 22 Nov, 2023 1 commit
  7. 07 Nov, 2023 1 commit
  8. 01 Nov, 2023 1 commit
  9. 30 Oct, 2023 1 commit
  10. 25 Oct, 2023 1 commit
  11. 12 Oct, 2023 1 commit
  12. 28 Sep, 2023 1 commit
  13. 27 Sep, 2023 1 commit
  14. 26 Sep, 2023 1 commit
    • Victoria Ashworth's avatar
      Wait for CONFIGURATION_BUILD_DIR to update when debugging with Xcode (#135444) · 3cfe3720
      Victoria Ashworth authored
      So there appears to be a race situation between the flutter CLI and Xcode. In the CLI, we update the `CONFIGURATION_BUILD_DIR` in the Xcode build settings and then tell Xcode to install, launch, and debug the app. When Xcode installs the app, it should use the `CONFIGURATION_BUILD_DIR` to find the bundle. However, it appears that sometimes Xcode hasn't processed the change to the build settings before the install happens, which causes it to not be able to find the bundle.
      
      Fixes https://github.com/flutter/flutter/issues/135442
      
      --- 
      
      Since it's a timing issue, there's not really a consistent way to test it.
      
      I was able to confirm that it works, though, by using the following steps:
      1. Create a flutter project
      2. Open the project in Xcode
      3. `flutter clean`
      4. `flutter run --profile -v`
      
      If I saw a print line `stderr: CONFIGURATION_BUILD_DIR: build/Debug-iphoneos`, that means it first found the old and incorrect `CONFIGURATION_BUILD_DIR` before updating to the the new, so I was able to confirm that it would wait until it updated.
      3cfe3720
  15. 20 Sep, 2023 1 commit
  16. 18 Sep, 2023 1 commit
    • Victoria Ashworth's avatar
      Don't uninstall before retrying to connect during app launch (#134542) · abf8361a
      Victoria Ashworth authored
      When retrying to connect to the device during app launch, don't uninstall the app first.
      
      Latest test flake for https://github.com/flutter/flutter/issues/120808:
      https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8770202475999850785/+/u/run_hot_mode_dev_cycle_ios__benchmark/test_stdout
      
      Shows that it uninstalled and then tried debugging and failed, which would make sense since the app wasn't installed anymore.
      ```
      [2023-09-11 18:02:24.555646] [STDOUT] stdout: [   +6 ms] Lost connection to device. Trying to connect again...
      [2023-09-11 18:02:24.556949] [STDOUT] stdout: [   +1 ms] executing: /opt/s/w/ir/x/w/recipe_cleanup/tmp53fs1szo/flutter sdk/bin/cache/artifacts/libimobiledevice/idevicesyslog -u 00008030-00144DA10185402E
      [2023-09-11 18:02:24.557323] [STDOUT] stdout: [        ] executing: script -t 0 /dev/null /opt/s/w/ir/x/w/recipe_cleanup/tmp53fs1szo/flutter sdk/bin/cache/artifacts/ios-deploy/ios-deploy --id 00008030-00144DA10185402E --bundle build/ios/iphoneos/Flutter Gallery.app --app_deltas build/ios/app-delta --uninstall --noinstall --debug --no-wifi --args --enable-dart-profiling --disable-vm-service-publication --enable-checked-mode --verify-entry-points
      [2023-09-11 18:02:24.578010] [STDOUT] stdout: [  +20 ms] [....] Waiting for iOS device to be connected
      [2023-09-11 18:02:24.712631] [STDOUT] stdout: [ +134 ms] [....] Using 00008030-00144DA10185402E (N104AP, iPhone 11, iphoneos, arm64e, 16.2, 20C65) a.k.a. 'iPhone 11'.
      [2023-09-11 18:02:24.712725] [STDOUT] stdout: [        ] ------ Uninstall phase ------
      [2023-09-11 18:02:24.818293] [STDOUT] stdout: [ +105 ms] [ OK ] Uninstalled package with bundle id io.flutter.examples.gallery
      [2023-09-11 18:02:24.906833] [STDOUT] stdout: [  +88 ms] ------ Debug phase ------
      [2023-09-11 18:02:24.906924] [STDOUT] stdout: [        ] Starting debug of 00008030-00144DA10185402E (N104AP, iPhone 11, iphoneos, arm64e, 16.2, 20C65) a.k.a. 'iPhone 11' connected through USB...
      [2023-09-11 18:02:25.285252] [STDOUT] stdout: [ +378 ms] [  0%] Looking up developer disk image
      [2023-09-11 18:02:25.529937] [STDOUT] stdout: [ +244 ms] [ 90%] Mounting developer disk image
      [2023-09-11 18:02:25.545261] [STDOUT] stdout: [  +15 ms] [ 95%] Developer disk image already mounted
      [2023-09-11 18:02:25.587923] [STDOUT] stdout: [  +42 ms] Detected path to iOS debug symbols: "Symbol Path: /Users/swarming/Library/Developer/Xcode/iOS DeviceSupport/16.2 (20C65) arm64e/Symbols"
      [2023-09-11 18:02:25.857177] [STDOUT] stdout: [ +269 ms] Script started, output file is /dev/null
      [2023-09-11 18:02:25.857259] [STDOUT] stdout: [        ] Script done, output file is /dev/null
      [2023-09-11 18:02:25.857511] [STDOUT] stdout: [        ] ios-deploy exited with code 0
      [2023-09-11 18:02:25.858066] [STDOUT] stderr: [        ] Could not run build/ios/iphoneos/Flutter Gallery.app on 00008030-00144DA10185402E.
      [2023-09-11 18:02:25.858130] [STDOUT] stderr: [        ] Try launching Xcode and selecting "Product > Run" to fix the problem:
      [2023-09-11 18:02:25.858214] [STDOUT] stderr: [        ]   open ios/Runner.xcworkspace
      [2023-09-11 18:02:25.858537] [STDOUT] stdout: [        ] Installing and launching... (completed in 52.4s)
      [2023-09-11 18:02:25.858956] [STDOUT] stderr: [        ] Error launching application on iPhone 11.
      ```
      abf8361a
  17. 13 Sep, 2023 1 commit
  18. 10 Sep, 2023 1 commit
    • Daco Harkes's avatar
      Native assets support for MacOS and iOS (#130494) · aa36db1d
      Daco Harkes authored
      Support for FFI calls with `@Native external` functions through Native assets on MacOS and iOS. This enables bundling native code without any build-system boilerplate code.
      
      For more info see:
      
      * https://github.com/flutter/flutter/issues/129757
      
      ### Implementation details for MacOS and iOS.
      
      Dylibs are bundled by (1) making them fat binaries if multiple architectures are targeted, (2) code signing these, and (3) copying them to the frameworks folder. These steps are done manual rather than via CocoaPods. CocoaPods would have done the same steps, but (a) needs the dylibs to be there before the `xcodebuild` invocation (we could trick it, by having a minimal dylib in the place and replace it during the build process, that works), and (b) can't deal with having no dylibs to be bundled (we'd have to bundle a dummy dylib or include some dummy C code in the build file).
      
      The dylibs are build as a new target inside flutter assemble, as that is the moment we know what build-mode and architecture to target.
      
      The mapping from asset id to dylib-path is passed in to every kernel compilation path. The interesting case is hot-restart where the initial kernel file is compiled by the "inner" flutter assemble, while after hot restart the "outer" flutter run compiled kernel file is pushed to the device. Both kernel files need to contain the mapping. The "inner" flutter assemble gets its mapping from the NativeAssets target which builds the native assets. The "outer" flutter run get its mapping from a dry-run invocation. Since this hot restart can be used for multiple target devices (`flutter run -d all`) it contains the mapping for all known targets.
      
      ### Example vs template
      
      The PR includes a new template that uses the new native assets in a package and has an app importing that. Separate discussion in: https://github.com/flutter/flutter/issues/131209.
      
      ### Tests
      
      This PR adds new tests to cover the various use cases.
      
      * dev/devicelab/bin/tasks/native_assets_ios.dart
        * Runs an example app with native assets in all build modes, doing hot reload and hot restart in debug mode.
      * dev/devicelab/bin/tasks/native_assets_ios_simulator.dart
        * Runs an example app with native assets, doing hot reload and hot restart.
      * packages/flutter_tools/test/integration.shard/native_assets_test.dart
        * Runs (incl hot reload/hot restart), builds, builds frameworks for iOS, MacOS and flutter-tester.
      * packages/flutter_tools/test/general.shard/build_system/targets/native_assets_test.dart
        * Unit tests the new Target in the backend.
      * packages/flutter_tools/test/general.shard/ios/native_assets_test.dart
      * packages/flutter_tools/test/general.shard/macos/native_assets_test.dart
        * Unit tests the native assets being packaged on a iOS/MacOS build.
      
      It also extends various existing tests:
      
      * dev/devicelab/bin/tasks/module_test_ios.dart
         * Exercises the add2app scenario.
      * packages/flutter_tools/test/general.shard/features_test.dart
         * Unit test the new feature flag.
      aa36db1d
  19. 05 Sep, 2023 1 commit
  20. 18 Aug, 2023 1 commit
  21. 15 Aug, 2023 1 commit
  22. 14 Aug, 2023 1 commit
    • Victoria Ashworth's avatar
      Fix log filtering and CI tests for iOS 17 physical devices (#132491) · ec0b7443
      Victoria Ashworth authored
      Fixes a couple of issues introduced in new iOS 17 physical device tooling: https://github.com/flutter/flutter/pull/131865.
      
      1) Duplicate messages were being filtered out too aggressively. 
      
      For example, if on the counter app, you printed "Increment!" on button click, it would only print once no matter how many times you clicked.
      
      Sometimes more than one log source is used at a time and the original intention was to filter duplicates between two log sources, so it wouldn't print the same message from both logs. However, it would also filter when the same message was added more than once via the same log.
      
      The new solution distinguishes a "primary" and a "fallback" log source and prefers to use the primary source unless it's not working, in which it'll use the fallback. If the fallback is faster than the primary, the primary will exclude the logs received by the fallback in a 1-to-1 fashion to prevent too-aggressive filtering. Once a flutter-message has been received by the primary source, fallback messages will be ignored.
      
      Note: iOS < 17 did not regress.
      
      2) There was a race condition between the shutdown hooks and exiting XcodeDebug that was causing a crash when deleting a file that doesn't exist. This only affects CI  - for the new integration tests and when testing with iOS 17 physical devices.
      ec0b7443
  23. 09 Aug, 2023 1 commit
    • Victoria Ashworth's avatar
      New tooling for iOS 17 physical devices (#131865) · d631b262
      Victoria Ashworth authored
      This PR includes the following changes. These changes only apply to iOS 17 physical devices.
      
      | Command | Change Description  | Changes to User Experience |
      | ------------- | ------------- | ------------- |
      | `flutter run --release` | Uses `devicectl` to install and launch application in release mode.  | No change.  |
      | `flutter run`  | Uses Xcode via automation scripting to run application in debug and profile mode. | Xcode will be opened in the background. Errors/crashes may be caught in Xcode and therefore may not show in terminal. |
      | `flutter run --use-application-binary=xxxx` | Creates temporary empty Xcode project and use Xcode to run via automation scripting in debug and profile. | Xcode will be opened in the background. Errors/crashes may be caught in Xcode and therefore may not show in terminal.  |
      | `flutter install` | Uses `devicectl` to check installed apps, install app, uninstall app.  | No change.  |
      | `flutter screenshot` | Will return error.  | Will return error.  |
      
      Other changes include:
      * Using `devicectl` to get information about the device
      * Using `idevicesyslog` and Dart VM logging for device logs
      
      Note:
      Xcode automation scripting (used in `flutter run` for debug and profile) does not work in a headless (without a UI) interface. No known workaround.
      
      Fixes https://github.com/flutter/flutter/issues/128827, https://github.com/flutter/flutter/issues/128531.
      d631b262
  24. 04 Aug, 2023 1 commit
    • Victoria Ashworth's avatar
      Check for simulator runtime in flutter doctor (#131795) · b39604e0
      Victoria Ashworth authored
      Redo of https://github.com/flutter/flutter/pull/130728 - code is the same as before. That PR was stuck in Google testing and then I messed up the rebase so started over.
      
      ----
      
      Starting in Xcode 15, the simulator is no longer included in Xcode and must be downloaded and installed separately. This adds a validation to `flutter doctor` to warn when the needed simulator runtime is missing.
      
      Validation message looks like:
      ```
      [!] Xcode - develop for iOS and macOS (Xcode 15.0)
          ! iOS 17.0 Simulator not installed; this may be necessary for iOS and macOS development.
            To download and install the platform, open Xcode, select Xcode > Settings > Platforms,
            and click the GET button for the required platform.
      
            For more information, please visit:
              https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
      ```
      
      It may also show an error like this when something goes wrong when checking for the simulator:
      ```
      [!] Xcode - develop for iOS and macOS (Xcode 15.0)
          ✗ Unable to find the iPhone Simulator SDK.
      ```
      
      Note: I'm unsure of in the future if the SDK and the simulator runtime will need to match the exact version or just the major. For now, it only checks against the major version.
      
      Part 3 of https://github.com/flutter/flutter/issues/129558.
      b39604e0
  25. 13 Jul, 2023 3 commits
  26. 07 Jul, 2023 1 commit
  27. 06 Jul, 2023 1 commit
  28. 20 Jun, 2023 1 commit
  29. 02 Jun, 2023 1 commit
  30. 26 May, 2023 1 commit
  31. 24 May, 2023 1 commit
  32. 23 May, 2023 2 commits
  33. 22 May, 2023 1 commit
  34. 19 May, 2023 1 commit
  35. 15 May, 2023 1 commit
  36. 03 May, 2023 1 commit
  37. 02 May, 2023 1 commit
    • Jenn Magder's avatar
      Migrate Xcode projects last version checks to Xcode 14.3 (#125827) · 1861ac47
      Jenn Magder authored
      1. Add iOS and macOS migration to mark "last upgraded" Xcode version to 14.3 to prevent `Update to recommended settings` warning.
      2. Update iOS and macOS templates to same.
      3. Update iOS template to set `BuildIndependentTargetsInParallel` to YES as suggested.  I didn't add a migration for this since it seems like a minor optimization and I don't think it's worth a potentially botched/corrupted migration.
      4. Run all example/integration test project to see migrator work.
      5. Add some missing test projects to the build shard since I noticed they were missing and I had to build those manually outside `SHARD=build_tests`.
      
      Fixes https://github.com/flutter/flutter/issues/125817
      See https://github.com/flutter/flutter/pull/90304 for Xcode 13 example.
      1861ac47