Change from using `defaults` to `plutil` for Plist parsing (#38662)
We were using the `defaults` command-line utility to parse
Plist files, but it was never supported by Apple, and it
appears that in an upcoming OS release, it will be less likely
to work:
> WARNING: The defaults command will be changed in an upcoming
> major release to only operate on preferences domains. General
> plist manipulation utilities will be folded into a different
> command-line program.
Fixes https://github.com/flutter/flutter/issues/37701
diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index ef83cfe..1e99c89 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -17,8 +17,7 @@
import 'features.dart';
import 'flutter_manifest.dart';
import 'globals.dart';
-import 'ios/ios_workflow.dart';
-import 'ios/plist_utils.dart' as plist;
+import 'ios/plist_parser.dart';
import 'ios/xcodeproj.dart' as xcode;
import 'plugins.dart';
import 'template.dart';
@@ -361,10 +360,15 @@
/// The product bundle identifier of the host app, or null if not set or if
/// iOS tooling needed to read it is not installed.
String get productBundleIdentifier {
- final String fromPlist = iosWorkflow.getPlistValueFromFile(
- hostInfoPlist.path,
- plist.kCFBundleIdentifierKey,
- );
+ String fromPlist;
+ try {
+ fromPlist = PlistParser.instance.getValueFromFile(
+ hostInfoPlist.path,
+ PlistParser.kCFBundleIdentifierKey,
+ );
+ } on FileNotFoundException {
+ // iOS tooling not found; likely not running OSX; let [fromPlist] be null
+ }
if (fromPlist != null && !fromPlist.contains('\$')) {
// Info.plist has no build variables in product bundle ID.
return fromPlist;