Skip to content

Check Xcode build setting FULL_PRODUCT_NAME for bundle name - #55799

Merged
jmagman merged 5 commits into
flutter:masterfrom
jmagman:handle-non-runner
May 4, 2020
Merged

jmagman merged 5 commits into
flutter:masterfrom
jmagman:handle-non-runner

Conversation

@jmagman

@jmagman jmagman commented Apr 28, 2020 •

Copy link
Copy Markdown
Member

Another attempt at #46838.

Description

Users who update their app's display name from Xcode's UI (what gets shown on the home screen under the icon) can no longer flutter run. Xcode sets PRODUCT_NAME to whatever is input to General > Display Name, and that's used to name the My App.app app product (spaces and all).

  • Don't hardcode the product name to Runner.app during a run or install. Get it from Xcode build setting FULL_PRODUCT_NAME.
  • Fix the logging regex to handle the actual product name instead of Runner.

This will still work for "legacy" apps called Runner.app or with a display name hard-coded in the Info.plist.

Related Issues

Fixes #41793
See also #9767 (comment)

Tests

Updated:

  • ios_device_start_nonprebuilt_test
  • mac_test
  • simulators_test
  • project_test

Update gallery integration test to set the name in the project instead of the Info.plist (the default way Xcode projects and macOS Flutter Xcode projects are named).

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.

@jmagman jmagman self-assigned this Apr 28, 2020
@fluttergithubbot fluttergithubbot added c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Apr 28, 2020
@jmagman jmagman added t: xcode "xcodebuild" on iOS and general Xcode project management and removed cla: yes labels Apr 28, 2020
@jmagman
jmagman force-pushed the handle-non-runner branch from 18e4c0c to cff5437 Compare April 28, 2020 01:02
@jmagman jmagman mentioned this pull request Apr 28, 2020
9 of 10 tasks
@jmagman
jmagman force-pushed the handle-non-runner branch 2 times, most recently from daea0f6 to 2f88ead Compare April 29, 2020 20:55
@jmagman
jmagman marked this pull request as ready for review April 29, 2020 20:56
@christopherfujino

Copy link
Copy Markdown
Contributor

@jmagman I remember reviewing #46838. Can you give me the tl;dr on why it was reverted (was it because of basic_material_app_ios__compile?) and the differences in this PR?

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jmagman I remember reviewing #46838. Can you give me the tl;dr on why it was reverted (was it because of basic_material_app_ios__compile?) and the differences in this PR?

Yes, sorry meant to do this!

There are three main changes:

  1. I renamed the Flutter Gallery integration test in Xcode's UI (details inline in comment).
  2. The pre-iOS 11 simulator logs need to be parsed to handle older versions of log lines. This caused the original revert. (details inline in comment).
  3. The creation template has not been changed. That was the riskiest part of #46838, and upon further thought, isn't really necessary. We can leave as-is with the name being set in the Info.plist, but make sure we handle if users change the Display Name from Xcode's UI (the way you're really supposed to do this).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  1. I renamed the Flutter Gallery integration test in Xcode's UI, which names in the project, not the Info.plist.
    This project is used in Cirrus and devicelab tests, any if it can flutter run with a "Flutter Gallery.app" instead of "Runner.app" then it proves this works.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  1. The last attempt at this PR was reverted because of a g3 test that checked the format of a simulator log from some older iOS SDK. I added that test at Add iOS simulator log parse test #55808, and it passes in this PR.

This code is filtering out log lines that come from an app other than this one (category doesn't match the app name). The previous regex assumed the app name was one word (Runner), but now we don't know how many words it will be, and it's hard to separate it out from the hostname, plus we don't know how many tokens the date will have since it's different formats across iOS SDKs. So now it checks if anything after the date (green match below) ENDS in the app name instead of exactly matches.

Screen Shot 2020-04-30 at 10 29 36 AM

@christopherfujino christopherfujino Apr 30, 2020 •

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.

This is a great comment, very clear (and the screenshot helps as well). That being said, I was completely bewildered from just reading the code. Do you think you can add more context to the comments here (especially why you're using .endsWith()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

category != _appName && !category.endsWith(' $_appName') is redundant.

@jmagman
jmagman force-pushed the handle-non-runner branch from e7d8b63 to 85013ff Compare April 30, 2020 18:09

@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, with a nit about additional comments about the log parsing change.

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.

nit: avoid getters that do work: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#getters-feel-faster-than-methods

The way we usually set this up is to have a private _ hostAppBundleName, and then a _compute HostAppBundleName that initializes the field:

int _foo;
int _computeFoo();
int get foo => _foo ??= _computeFoo();
``

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will swap productBundleIdentifier too.

@jmagman
jmagman force-pushed the handle-non-runner branch from 85013ff to ab8bf1b Compare May 1, 2020 03:05

@jonahwilliams jonahwilliams 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

@jmagman
jmagman merged commit c8c55b4 into flutter:master May 4, 2020
@jmagman
jmagman deleted the handle-non-runner branch May 4, 2020 18:31
@stuartmorgan-g

Copy link
Copy Markdown
Contributor

Sorry for not reviewing; I was OOO Thu-Mon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After app rename, build error: Could not find the built application bundle at build/ios/iphonesimulator/Runner.app

6 participants