[CP-beta][ios26]Do not report error for Info.plist key not found#173438
Conversation
In xcode_backend's `runSync` function, there's a flag parameter `allowFail`. The purpose of this flag is that, when enabled, even if command fails, we should not fail Xcode. However, the current implementation has a bug, that even when `allowFail = true`, we still prefix `"error:"` string to `stderr`, which causes Xcode compilation error. Before macOS 26, plutil used `stdout` rather than `stderr`, so the bug was not surfaced. On macOS 26, pltuil uses `stderr` instead (which makes sense), so the bug is surfaced now. Note: even if plutil doesn't change behavior on macOS 26, if I randomly come across this code, I'd still fix the logic error. *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* Fixes flutter#172627 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [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 `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Jenn Magder <magder@google.com>
|
@jmagman please fill out the PR description above, afterwards the release team will review this request. |
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request prevents Xcode build failures when plutil reports a missing key in Info.plist, which is a behavior change in newer macOS versions. The change correctly uses the allowFail flag to suppress build errors in this case. The logic is sound, and the change is well-tested with new unit and integration tests. I've only found a minor opportunity to reduce code duplication in the new unit tests for better maintainability.
| final Directory buildDir = fileSystem.directory('/path/to/builds') | ||
| ..createSync(recursive: true); | ||
| final File infoPlist = buildDir.childFile('Info.plist')..createSync(); | ||
| final context = TestContext( | ||
| <String>['test_vm_service_bonjour_service'], | ||
| <String, String>{ | ||
| 'CONFIGURATION': 'Debug', | ||
| 'BUILT_PRODUCTS_DIR': buildDir.path, | ||
| 'INFOPLIST_PATH': 'Info.plist', | ||
| }, |
There was a problem hiding this comment.
There's some duplicated setup code between this test and the next one ('Missing NSLocalNetworkUsageDescription in Info.plist should not fail Xcode compilation'). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, you could extract the common setup into a setUp function within the group. This aligns with the style guide's principles of optimizing for readability and avoiding duplication.1
For example:
group('test_vm_service_bonjour_service', () {
late Directory buildDir;
late File infoPlist;
setUp(() {
buildDir = fileSystem.directory('/path/to/builds')..createSync(recursive: true);
infoPlist = buildDir.childFile('Info.plist')..createSync();
});
// ... existing tests ...
test('Missing NSBonjourServices key in Info.plist should not fail Xcode compilation', () {
final context = TestContext(
<String>['test_vm_service_bonjour_service'],
<String, String>{
'CONFIGURATION': 'Debug',
'BUILT_PRODUCTS_DIR': buildDir.path,
'INFOPLIST_PATH': 'Info.plist',
},
// ... rest of the test where infoPlist.path is used for FakeCommands
);
// ...
});
// ... and so on for the other test.
});Style Guide References
Footnotes
There was a problem hiding this comment.
I'm assuming this is not the time to DRY up this test, FYI @vashworth.
| final Directory buildDir = fileSystem.directory('/path/to/builds') | ||
| ..createSync(recursive: true); | ||
| final File infoPlist = buildDir.childFile('Info.plist')..createSync(); | ||
| final context = TestContext( | ||
| <String>['test_vm_service_bonjour_service'], | ||
| <String, String>{ | ||
| 'CONFIGURATION': 'Debug', | ||
| 'BUILT_PRODUCTS_DIR': buildDir.path, | ||
| 'INFOPLIST_PATH': 'Info.plist', | ||
| }, |
There was a problem hiding this comment.
I'm assuming this is not the time to DRY up this test, FYI @vashworth.
40aecd7
into
flutter:flutter-3.35-candidate.0
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
What is the link to the issue this cherry-pick is addressing?
#172627
Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples
Prevents a non-fatal error from causing Xcode compilation failures on macOS 26.
Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)
Building iOS flutter apps may crash with Xcode 26.
Workaround:
Is there a workaround for this issue?
Add NSBonjourServices and NSLocalNetworkUsageDescription settings to your iOS app's Info.plist.
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
What are the steps to validate that this fix works?
flutter createa new app on macOS 26 betaflutter run