Context: https://github.com/flutter/flutter/issues/131862
This PR injects a "realm" component to the storage base URL when the contents of the file `bin/internal/engine.realm` is non-empty.
As documented in the PR, when the realm is `flutter_archives_v2`, and `bin/internal/engine.version` contains the commit hash for a commit in a `flutter/engine` PR, then the artifacts pulled by the tool will be the artifacts built by the presubmit checks for the PR.
This works for everything but the following two cases:
1. Fuchsia artifacts are not uploaded to CIPD by the Fuchsia presubmit builds.
2. Web artifacts are not uploaded to gstatic by the web engine presubmit builds.
For (1), the flutter/flutter presubmit `fuchsia_precache` is driven by a shell script outside of the repo. It will fail when the `engine.version` and `engine.realm` don't point to a post-submit engine commit.
For (2), the flutter/flutter web presubmit tests that refer to artifacts in gstatic hang when the artifacts aren't found, so this PR skips them.
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.
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.
Fixed code for the Uri as it includes the period at the end as the part of Uri parsing previously.
As for example:
```
A crash report has been written to /Users/andrewkolos/Desktop/asset_transformers_test/flutter_03.log.
```
Many terminals are unable to follow the link because it includes the period in the end as part of it. This PR simply removes the period in the end so that it is clickable in many systems (e.g. by `alt` -clicking on it in an embedded bash terminal, VSCode).
```
A crash report has been written to /Users/andrewkolos/Desktop/asset_transformers_test/flutter_03.log
```
Fixes: #131166
In the legacy VS Code DAP, we would deserialise the Flutter.Error event
and provide some basic colouring (eg. stack frames are faded if not from
user code and the text is split between stdout/stderr to allow the
client to colour it).
In the new DAPs we originally used `renderedErrorText` which didn't
support either of these. This change adds changes to use the structured
data (with some basic parsing because the source classes are in
package:flutter and not accessible here) to provide a similar
experience.
It would be nicer if we could use the real underlying Flutter classes
for this deserialisation, but extracting them from `package:flutter` and
removing all dependencies on Flutter is a much larger job and I don't
think should hold up providing improved error formatting for the new
DAPs.
Some comparisons:


Improves #119596. The tests remain valid, so no tests were updated in the request.
This does not resolve issue #128932, it's handled by another part of the code.
To preserve backward compatibility with the old parser which would
ignore syntax errors, this PR introduces a way to treat the special
characters `{` and `}` in the following way:
1. If we encounter a `{` which searching for a string token and this `{`
is not followed by a valid placeholder, then we treat the `{` as a
string and continue lexing for strings.
2. If we encounter a `}` while not within some expression (i.e.
placeholders, arguments, plurals, or selects), then we treat the `}` as
a string and continue lexing for strings.
This makes it so that
```
"helloWorld": "{ } { placeholder }",
"@@helloWorld": {
"placeholders": {
"placeholder" {}
}
}
```
treats the `{ }` as a string while `{ placeholder } ` is treated as a
placeholder.
Fixes https://github.com/flutter/flutter/issues/122404.
The display name will fallback to CFBundleName if CFBundleDisplayName is absent.
*List which issues are fixed by this PR. You must list at least one issue.*
Fixes https://github.com/flutter/flutter/issues/120553
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
The daemon ignores all device discovery that is not a PollingDeviceDiscovery. Make ProxiedDevices a PollingDeviceDiscovery so that it can be used in flutter daemon.
Note that there is a TODO item added in the test, which I intend to attempt fixing in a subsequent PR.
PR provides a new option to the `test` command to include coverage info of specified packages.
It helps collecting coverage info in test setups where test code lives in separate packages or for multi-package projects.
At present, only current package is included to the final report.
Usage:
Consider an app with two packages: `app`, `common`.
Some of the tests in `app` use (indirectly) code that is located in `common`. When running with `--coverage` flag, that code is not included in the coverage report by default. To include `common` package in report, we can run:
```sh
flutter test --coverage --coverage-package app --coverage-package common
```
Note that `--coverage-package` accepts regular expression.
Fixes https://github.com/flutter/flutter/issues/79661
Fixes https://github.com/flutter/flutter/issues/101486
Fixes https://github.com/flutter/flutter/issues/93619
Fixed types for `_getNewServiceWorker` and `_waitForServiceWorkerActivation` functions.
These functions currently expect a Promise as an argument, but we're actually passing in an already resolved value:
```js
.then(this._getNewServiceWorker)
.then(this._waitForServiceWorkerActivation);
```
This migrator will upgrade the minSdkVersion used in the [module-level build.gradle](https://developer.android.com/build#module-level) file to flutter.minSdkVersion.
The PR also makes a small refactor to `AndroidProject` to add a getter for the module level build.gradle file, and uses that getter in places where we were getting that file (previously it was being gotten directly via `hostAppGradleRoot.childDirectory('app').childFile('build.gradle')`.
Part of the work for deprecating support for the Jelly Bean android apis.
Closes https://github.com/flutter/flutter/issues/80013.
**Before**:
```
$ flutter create test1 --description "a: b"
Creating project test1...
Error detected in pubspec.yaml:
Error on line 2, column 15: Mapping values are not allowed here. Did you miss a colon earlier?
â·
2 â description: a: b
â ^
âµ
Please correct the pubspec.yaml file at /Users/matan/Developer/scratch/test1/pubspec.yaml
```
**After**:
```
$ flutter create test1 --description "a: b"
Creating project test1...
Resolving dependencies in test1...
Got dependencies in test1.
Wrote 129 files.
All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd test1
$ flutter run
Your application code is in test1/lib/main.dart.
```
---
It's worth noting that this _always_ escapes a non-empty project description, which means that descriptions that were not previously wrapped in `"`s' will be. I'm not sure how worth it is to do a _conditional_ escape (i.e. only escape if not escaping would cause a problem), but willing to change.
Side-note: I had no idea where to list this test in the (very large) `create_test.dart`, so I did my best :)
Starting in Xcode 15, the simulator is no longer included in Xcode and must be downloaded and installed separately.
If you try to run flutter and the simulator is missing, you'll get an error like
```
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id:B1234A5C-67B8-901D-B2CB-FE34F56BDE78 }
Ineligible destinations for the "Runner" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 17.0 is not installed. To use with Xcode, first download and install the platform }
```
Print a pretty error to make it easier for developers to know what to do.
Part 2 of https://github.com/flutter/flutter/issues/129558.
This PR fixes ignoring when random positional arguments added to the
`flutter gen-l10n`.
So we are no longer able to call `flutter gen-l10n hello world` or
`flutter gen-l10n --format false`.
Fixes https://github.com/flutter/flutter/issues/118203
`resultBundlePath` is meant to be a directory. In the `xcodebuild --help`, it describes it as a directory:
```
-resultBundlePath PATH specifies the directory where a result bundle describing what occurred will be placed
```
This PR changes our usage of it from a file to a directory so that it gets deleted correctly between reruns.
Fixes https://github.com/flutter/flutter/issues/129954.
Adding debugging for https://github.com/flutter/flutter/issues/129836.
Takes a screenshot when startup test takes too long (10 minutes).
Also, removes some old debugging and add new debugging message.
The type variable `T`, when used as an expression, will always be a
`Type`. The type test `T is! List` is always true (as is `T is Type`).
This expression will become a warning in the analyzer in some upcoming
release of the Dart SDK.
This `assert` was added in a PR which reapplied an earlier PR, however
the earlier PR did not include this assert. I do not see any discussion
indicating the intent of this assert.
The impact of testing this `T` in any way is low - this is a private
class so we can see all the uses and know that the only type bound to
`T` is `Uri`. Avoid the upcoming diagnostic and remove the assert
entirely. This maintains existing behavior but ignores the potential
intent for the check.
To avoid analyzer warnings when utf8.encode() will return the more
precise Uint8List type, we use const Utf8Encoder().convert() which
already returns Uint8List
See https://github.com/dart-lang/sdk/issues/52801
**Original Description:**
> Service extensions are unable to handle requests when the isolate they
were registered on is paused. The DevTools launcher logic was waiting
for some service extension invocations to complete before advertising
the already active DevTools instance, but when --start-paused was
provided these requests would never complete, preventing users from
using DevTools to resume the paused isolate.
>
> Fixes https://github.com/flutter/flutter/issues/126691
**Additional changes in this PR:**
The failures listed in https://github.com/flutter/flutter/pull/128117
appear to be related to a shutdown race. It's possible for the test to
complete while the tool is in the process of starting and advertising
DevTools, so we need to perform a check of `_shutdown` in
`FlutterResidentDevtoolsHandler` before advertising DevTools.
Before the original fix, this check was being performed immediately
after invoking the service extensions, which creates an asynchronous gap
in execution. With #126698, the callsite of the service extensions was
moved and the `_shutdown` check wasn't, allowing for the tool to attempt
to advertise DevTools after the DevTools server had been cleaned up.
---------
Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com>
I intend to edit `toBeginningOfSentenceCase`'s return value to be non-nullable because it really is never null. That will mean that non-null asserts around it will become flagged as unnecessary, although right now they are necessary. So, apply a workaround - instead use a function that does a non-null assert without triggering any lints even after it becomes unnecessary.
Flutter web uses requireJS in `debug` mode to assemble a DDC-compiled app from a bunch of small files ("modules").
This caused that `canvaskit.js` (and all other modules that used a browserify-like loading header) didn't work because they attempted to use the `define` function provided by Flutter's instance of `requireJS` (which kept the defined modules private, rather than as globals on the page, as the users of the JS expected).
A [fix](https://github.com/flutter/engine/pull/27342) was added to `flutter/engine` to trick loaders into *not* using the `requireJS` module loader, but a recent change in the fix's js-interop layer *subtly* changed its JS output on the page (objects went from `undefined` to `null`), causing this:
* https://github.com/flutter/flutter/issues/126131 (and others)
This PR hides a bit of code that is commonly used by module loaders to decide that they may use the `define` function provided by requireJS (so the engine workaround can be removed).
## Next steps
* https://github.com/flutter/engine/pull/42941
## Issues
Partially addresses: https://github.com/flutter/flutter/issues/126131 (and others)
## Tests
* Added a unit test to ensure the `delete` stays
* Manually tested with the Gallery app in `debug` mode with a bunch of user-supplied scripts that currently fail to load.
* Also tested hot restart as suggested by @nshahan
Prevent the cli from crashing when a user selects a number that is not valid for `flutter run` device selection
Fixes issue:
- https://github.com/flutter/flutter/issues/129191
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
Refactor the globals getter for `Analytics` to be in the context instead of having a default fallback. The current state of the tool creates a new instance every time `globals.analytics` was called
Addresses issue:
- https://github.com/flutter/flutter/issues/128535
This PR fixes issue of duplicate entries from `xcdevice list` cause devices to not show in `flutter devices`, `flutter run`, etc.
When a duplicate entry is found, use the entry without errors as the authority. If both have errors, use the one with the higher SDK as the authority.
Fixes https://github.com/flutter/flutter/issues/128719.
The `getIsolate` method returns the full list of libraries which can be huge for large apps. Using the more speficic API to only fetch what we need improves hot reload performance.
*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*
*List which issues are fixed by this PR. You must list at least one issue.*
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
When building the new SDK DAPs, this functionality was missed from the Flutter adapter (but added to the Dart CLI adapter).
As well as passing a VM Service URI directly, we support passing a file that can be polled for it.
This uses the same mechanism we use to obtain the VM Service URI from a Dart debug session (we run `dart --write-service-info=foo.json my_file.dart` and then poll that file which the VM will write) and is useful for users that have their own mechanism for launching an app (for example using custom Flutter embedders - see https://github.com/Dart-Code/Dart-Code/issues/3353) to provide a VM Service URI once the app is up and running.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4577.
Fixes https://github.com/flutter/flutter/issues/112833
Most of the actual changes here are in [packages/flutter_tools/lib/src/version.dart](https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605), while the rest is largely just addressing changes to the constructor of `FlutterVersion` which now has different dependencies.
This change makes `FlutterVersion` an interface with two concrete implementations:
1. `_FlutterVersionGit` which is mostly the previous implementation, and
2. `_FlutterVersionFromFile` which will read a new `.version.json` file from the root of the repo
The [`FlutterVersion` constructor](https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605R70) is now a factory that first checks if `.version.json` exists, and if so returns an instance of `_FlutterVersionFromGit` else it returns the fallback `_FlutterVersionGit` which will end up writing `.version.json` so that we don't need to re-calculate the version on the next invocation.
`.version.json` will be deleted in the bash/batch entrypoints any time we need to rebuild he tool (this will usually be because the user did `flutter upgrade` or `flutter channel`, or manually changed the commit with git).
The current implementation of macOS flavor support (#119564) assumes a bundle directory that differs from both the iOS implementation and the official documentation. The [documentation](https://docs.flutter.dev/deployment/flavors) instructs developers to suffix their Xcode build configurations with `-<flavor>`, but the implementation assumes a space:
5fd9ef4240/packages/flutter_tools/lib/src/macos/application_package.dart (L174-L178)
Whereas the iOS implementation, which is the reference for the docs, assumes a `-<flavor>` suffix:
a257efc284/packages/flutter_tools/lib/src/ios/xcodeproj.dart (L482-L488)
This change replaces the empty space with the `-` character which is in line with the documentation and iOS implementation, as well as removing the sentence-casing applied to the flavor name; every bundle built with a flavor keeps the original flavor name in its filename.
*List which issues are fixed by this PR. You must list at least one issue.*
#122684.
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
Unpins flutter_plugin_android_lifecycle where it is pinned. I then
1. ran `flutter update-packages --force-upgrade` (but only committed the changes within `dev/integration_tests/gradle_deprecated_settings/`, which is where it had been pinned)
2. followed by `./gradlew :generateLockfiles` from `dev/integration_tests/gradle_deprecated_settings/android/` (the lockfile was what was causing the CI dependency resolution failure, so this second step is the fix for that).
See the reason it was pinned: https://github.com/flutter/flutter/pull/121847#discussion_r1124797112 followed by the PR that pinned it: https://github.com/flutter/flutter/pull/122043
Fixes https://github.com/flutter/flutter/issues/122039
Presubmit testing and CI testing of Flutter using a custom storage location for engine artifacts must be able to use the --fatal-warnings flag without failing due to the custom artifact location.
This change adds an option that makes this warning non-fatal. The new --no-fatal-storage-url-warning flag makes the --fatal-warnings flag ignore the warning that a custom artifact download URL is being used by setting the environment variable FLUTTER_STORAGE_BASE_URL.
Bug: #127683
- [X ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [X ] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
- [X ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
- [X ] I signed the [CLA].
- [X ] I listed at least one issue that this PR fixes in the description above.
- [X ] I updated/added relevant documentation (doc comments with `///`).
The editor is set to hot-reload-on-save by default so saving while the debug session is starting currently prints an error:
Failed to Hot Reload: app 'null' not found

This change skips the call to `app.restart` if the app hasn't started yet to avoid printing an error.
This PR adds uses of the `--target-os` command line argument when
building kernel sources for precompiled applications for supported
target operating systems. The Dart CFE then:
* treats `Platform.operatingSystem` as if it were defined as the
constant string provided as an argument to the flag,
* treats `Platform.pathSeparator` as the appropriate separator for that
operating system,
* attempts to constant evaluate the initializer for any field annotated
with the `vm:platform-const` pragma, and
* attempts to constant evaluate all calls to a method annotated with the
`vm:platform-const` pragma.
The `vm:platform-const` pragma can appear in either library or user
code. If the attempt to constant evaluate the field initializer or
method call fails, then an error is thrown at kernel compilation time.
Addresses #14233.
The tests in
`packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart`
have been adjusted properly to account for the new passed command line
arguments.
fixes https://github.com/flutter/flutter/issues/120408
Added two gradle tasks, one for grabing the application id, one for grabbing app link domains.
Added a new vmservices to call these two gradle tasks and return the result.
The expected work flow is that the devtool will first call a vmservices to grab all avaliable build variants. It will then choose one of the build variant and call this new services to get application id and app link domains.
Roll to engine to 4f4486b00be28183b482bbb74bbed25f4db153fe pick up dart to 3.1.0-169.0.dev.
Changes since last roll
```
4f4486b00b Roll dart to 3.1.0-169.0.dev (#42602)
```
Manual roll since rolling to dart 3.1.0-169.0.dev requires patching to expression evaluation in flutter tools
Closes https://github.com/flutter/flutter/issues/106416.
This PR adds a new `flutter config` setting named `jdk-dir`. When set, the tool will use the JDK found at this location for all Java-dependent tool operations such as building Android apps via gradle and running Android SDK tools.
Fixes https://github.com/flutter/flutter/issues/127090.
https://github.com/flutter/flutter/pull/122505 did a few things to speed up the first asset load that a flutter app performs. One of those things was to not include the main asset in its own list of variants in the asset manifest. The idea was that we know that the main asset always exists, so including it in its list of variants is a waste of storage space and loading time (even if the cost was tiny).
However, the assumption that the main asset always exists is wrong. From [Declaring resolution-aware image assets](https://docs.flutter.dev/ui/assets-and-images#resolution-aware), which predates https://github.com/flutter/flutter/pull/122505:
> Each entry in the asset section of the pubspec.yaml should correspond to a real file, with the exception of the main asset entry. If the main asset entry doesnât correspond to a real file, then the asset with the lowest resolution is used as the fallback for devices with device pixel ratios below that resolution. The entry should still be included in the pubspec.yaml manifest, however.
For example, it's valid to declare `assets/image.png` as an asset even if only `assets/3x/image.png` exists on disk.
This fix restores older behavior of including a main asset as a variant of itself in the manifest if it exists.
This fix also includes a non-user-visible behavior change:
* `"dpr"` is no longer a required field in the asset manifest's underlying structure. For the main asset entry, we do not include `"dpr"`. It makes less sense for the tool to decide what the default target dpr for an image should be. This should be left to the framework.
Always pass the space code point (`0x20`) to the font subsetter when targetting web because the web engine relies on that character to calculate a font's height.
Fixes#127270
Reverts flutter/flutter#126698
There are a bunch of tool crashes on CI that start with this commit. I'm
not sure this PR is the cause because there is no backtrace from the
tool on the crashes. The only error message is `Oops; flutter has exited
unexpectedly: "Null check operator used on a null value`.
Service extensions are unable to handle requests when the isolate they were registered on is paused. The DevTools launcher logic was waiting for some service extension invocations to complete before advertising the already active DevTools instance, but when --start-paused was provided these requests would never complete, preventing users from using DevTools to resume the paused isolate.
Fixes https://github.com/flutter/flutter/issues/126691
Fixes#122081.
When validating an Android Studio installation, add a warning validation message when we are unable to detect the version. This is because we have logic throughout the tool (JDK/JRE-searching) that is at higher risk of failing when we don't know the version.
Fixes#124252, finishing work on the umbrella tracking issue, #126126.
Essentially, after this PR, no (non-test) code should be be referencing/invoking the java home or binary paths.
Replace imports of `src/remote_listener.dart` with `backend.dart` which exports `RemoteListener`.
Remove the unused imports of `src/backend/stack_trace_formatter.dart` (no uses of `StackTraceFormatter`) and
`src/backend/suite_channel_manager.dart` (no uses of `SuiteChannelManager`).
This reverts commit a19b3436ee.
We added this logging to try and determine if the reason for Dart VM errors (https://github.com/flutter/flutter/issues/121231) was caused by some issue with the streams.
A recent test proves that is not the case:
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20platform_view_ios__start_up/11046/overview
The test shows the Dart VM url in the device log. However, the test log does NOT show a log for the Dart VM url but does show the stack trace, which all come from the main stream, which means it's not an issue with the secondary streams not receiving the log.
So reverting the debugging we added.
## How we determine the channel name
Historically, we used the current branch's upstream to figure out the current channel name. I have no idea why. I traced it back to https://github.com/flutter/flutter/pull/446/files where @abarth implement this and I reviewed that PR and left no comment on it at the time.
I think this is confusing. You can be on a branch and it tells you that your channel is different. That seems weird.
This PR changes the logic to uses the current branch as the channel name.
## How we display channels
The main reason this PR exists is to add channel descriptions to the `flutter channel` list:
```
ianh@burmese:~/dev/flutter/packages/flutter_tools$ flutter channel
Flutter channels:
master (tip of tree, for contributors)
main (tip of tree, follows master channel)
beta (updated monthly, recommended for experienced users)
stable (updated quarterly, for new users and for production app releases)
* foo_bar
Currently not on an official channel.
ianh@burmese:~/dev/flutter/packages/flutter_tools$
```
## Other changes
I made a few other changes while I was at it:
* If you're not on an official channel, we used to imply `--show-all`, but now we don't, we just show the official channels plus yours. This avoids flooding the screen in the case the user is on a weird channel and just wants to know what channel they're on.
* I made the tool more consistent about how it handles unofficial branches. Now it's always `[user branch]`.
* I slightly adjusted how unknown versions are rendered so it's clearer the version is unknown rather than just having the word "Unknown" floating in the output without context.
* Simplified some of the code.
* Made some of the tests more strict (checking all output rather than just some aspects of it).
* Changed the MockFlutterVersion to implement the FlutterVersion API more strictly.
* I made sure we escape the output to `.metadata` to avoid potential injection bugs (previously we just inlined the version and channel name verbatim with no escaping, which is super sketchy).
* Tweaked the help text for the `downgrade` command to be clearer.
* Removed some misleading text in some error messages.
* Made the `.metadata` generator consistent with the template file.
* Removed some obsolete code to do with the `dev` branch.
## Reviewer notes
I'm worried that there are implications to some of these changes that I am not aware of, so please don't assume I know what I'm doing when reviewing this code. :-)
Log all output of `ios-deploy` to try and determine if the issue of https://github.com/flutter/flutter/issues/121231 is with stream or with `ios-deploy`.
Note: This will cause some duplicate logs like example below but only in verbose mode
```
(lldb) 2023-05-19 13:48:19.107935-0500 Runner[2521:390363] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
(lldb) 2023-05-19 13:48:19.107935-0500 Runner[2521:390363] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
2023-05-19 13:48:19.156866-0500 Runner[2521:390612] flutter: The Dart VM service is listening on http://127.0.0.1:63508/IsFnhXJykCM=/
VM Service URL on device: http://127.0.0.1:63508/IsFnhXJykCM=/
```
## Background
The Windows runner has a race at startup:
1. **Platform thread**: creates a hidden window
2. **Platform thread**: launches the Flutter engine
3. **UI/Raster threads**: renders the first frame
4. **Platform thread**: Registers a callback to show the window once the next frame has been rendered.
Steps 3 and 4 happen in parallel and it is possible for step 3 to complete before step 4 starts. In this scenario, the next frame callback is never called and the window is never shown.
As a result the `windows_startup_test`'s test, which [verifies that the "show window" callback is called](1f09a8662d/dev/integration_tests/windows_startup_test/windows/runner/flutter_window.cpp (L60-L64)), can flake if the first frame is rendered before the show window callback has been registered.
## Solution
This change makes the runner schedule a frame after it registers the next frame callback. If step 3 hasn't completed yet, this no-ops as a frame is already scheduled. If step 3 has already completed, a new frame will be rendered, which will call the next frame callback and show the window.
Part of https://github.com/flutter/flutter/issues/119415
See this thread for alternatives that were considered: https://github.com/flutter/engine/pull/42061#issuecomment-1550080722
xcodebuild command generates a xcresult bundle file on each run, however, it doesn't delete the file generated from previous run and will throw an error if the exact file already exists.
In tool, we manually delete the file after each `flutter build` or `flutter run` command. However, there are some internal logic where xcodebuild retries multiple times.
This PR deletes the xcresult bundle file at the start of each retry if it exists.
Fixes https://github.com/flutter/flutter/issues/127119