Skip to content

Enable track widget creation when generating Generated.xcconfig - #101123

Merged
fluttergithubbot merged 4 commits into
flutter:masterfrom
yeatse:track-widget-creation
Apr 11, 2022
Merged

fluttergithubbot merged 4 commits into
flutter:masterfrom
yeatse:track-widget-creation

Conversation

@yeatse

@yeatse yeatse commented Mar 31, 2022 •

Copy link
Copy Markdown
Contributor

When initializing a flutter module project, flutter will generate a Generated.xcconfig for iOS, setting TRACK_WIDGET_CREATION=false. This file is used to generate flutter_export_environment.sh, and finally loaded by podhelper.rb to build into the host app. However when we run flutter attach to it, track-widget-creation defaults to true so hot reload breaks until we hot restart it.

This fix set TRACK_WIDGET_CREATION=true in Generated.xcconfig, making hot reload in add-to-app work as expected.

Fixes #94681

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 31, 2022
@christopherfujino

Copy link
Copy Markdown
Contributor

@jmagman can you take a look at this one?

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes to make this the default BuildInfo.debug behavior.

@yeatse

yeatse commented Apr 8, 2022

Copy link
Copy Markdown
Contributor Author

@jmagman Thanks for your review! Just updated BuildInfo.debug and a few test cases. Please take another look.

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor null nit.

Thanks for the contribution!

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jmagman jmagman added waiting for tree to go green platform-ios iOS applications specifically labels Apr 11, 2022
@fluttergithubbot

Copy link
Copy Markdown
Contributor

This pull request is not suitable for automatic merging in its current state.

  • Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@jmagman

jmagman commented Apr 11, 2022

Copy link
Copy Markdown
Member

Adding @christopherfujino for second review, forgot we needed that.

@christopherfujino christopherfujino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fluttergithubbot

Copy link
Copy Markdown
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 11, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 11, 2022
@yeatse
yeatse deleted the track-widget-creation branch April 12, 2022 00:28
patevs pushed a commit to patevs/flutter that referenced this pull request Nov 13, 2026
…le (flutter#196078)

Registers `BuildInfoOptions.trackWidgetCreation` in
`AppleBuildOptionsBundle` so Apple build subcommands (`build ios`,
`build ipa`, and `build macos`) register `--[no-]track-widget-creation`
(defaulting to on). Note that `--profile` AOT builds for `build ios` and
`build ipa` will also now compile with `--track-creation-locations` by
default (unless `--no-track-widget-creation` is passed), matching `build
macos`, `build apk`, `build appbundle`, and `flutter run --profile`.

This regression was originally introduced in
flutter#56094 (first shipped in Flutter
1.20.0). Prior to flutter#56094,
`xcodeproj.dart` omitted `TRACK_WIDGET_CREATION` from
`Generated.xcconfig` when `buildInfo.trackWidgetCreation` was `false`,
and `KernelSnapshot` enabled widget creation tracking whenever
`TrackWidgetCreation` was not `'false'`.
flutter#56094 switched `xcodeproj.dart`
to `buildInfo.toEnvironmentConfig()`, which unconditionally writes
`TRACK_WIDGET_CREATION=${trackWidgetCreation}`.

In flutter#101123 (fixing
flutter#94681), `BuildInfo.debug` was
updated to set `trackWidgetCreation: true`, which fixed
`Generated.xcconfig` for projects built directly from Xcode after
`flutter create` or `flutter pub get` (while `flutter run` already
registered `--track-widget-creation`). However, `BuildIOSCommand`
constructs its `BuildInfo` via `FlutterCommand.getBuildInfo()` and never
registered `--track-widget-creation` (an omission later carried forward
into `AppleBuildOptionsBundle` in
flutter#192818), so running `flutter
build ios --debug` overwrote `Generated.xcconfig` with
`TRACK_WIDGET_CREATION=false` and caused the first hot reload after
`flutter attach` to fail with `Lookup failed: _location`.

Previous output:
```
+13: ios build debug config-only writes TRACK_WIDGET_CREATION=true to Generated.xcconfig by default

Expected: contains 'TRACK_WIDGET_CREATION=true'
  Actual: '// This is a generated file; do not edit or check into version control.\n'
            'FLUTTER_ROOT=/usr/local/google/home/bkonyi/.gemini/jetski/worktrees/flutter/issue-195792\n'
            'FLUTTER_APPLICATION_PATH=/\n'
            'FLUTTER_FRAMEWORK_SWIFT_PACKAGE_PATH=/ios/Flutter/ephemeral/Packages/.packages/FlutterFramework\n'
            'COCOAPODS_PARALLEL_CODE_SIGN=true\n'
            'FLUTTER_TARGET=lib/main.dart\n'
            'FLUTTER_BUILD_DIR=build\n'
            'FLUTTER_BUILD_NAME=1.0.0\n'
            'FLUTTER_BUILD_NUMBER=1\n'
            'EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386\n'
            'EXCLUDED_ARCHS[sdk=iphoneos*]=armv7\n'
            'DART_DEFINES=RkxVVFRFUl9WRVJTSU9OPTAuMC4w,RkxVVFRFUl9DSEFOTkVMPW1hc3Rlcg==,RkxVVFRFUl9HSVRfVVJMPWh0dHBzOi8vZ2l0aHViLmNvbS9mbHV0dGVyL2ZsdXR0ZXIuZ2l0,RkxVVFRFUl9GUkFNRVdPUktfUkVWSVNJT049MTExMTE=,RkxVVFRFUl9FTkdJTkVfUkVWSVNJT049YWJjZGU=,RkxVVFRFUl9EQVJUX1ZFUlNJT049MTI=\n'
            'DART_OBFUSCATION=false\n'
            'TRACK_WIDGET_CREATION=false\n'
            'TREE_SHAKE_ICONS=false\n'
            'PACKAGE_CONFIG=/.dart_tool/package_config.json\n'
            ''
   Which: does not contain 'TRACK_WIDGET_CREATION=true'
```

Current output:
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/worktrees/flutter/issue-195792/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart
00:00 +0: (setUpAll)
00:00 +0: ios build debug config-only writes TRACK_WIDGET_CREATION=true to Generated.xcconfig by default
00:00 +1: (tearDownAll)
00:00 +1: All tests passed!
```

Fixes flutter#195792
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS add-to-app fullscreen example can not hot reload until hot restart

5 participants