Only try to get build settings if the Xcode project exists (#61979)

diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index 156d78e..045b1e6 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -521,7 +521,7 @@
   Map<String, Map<String, String>> _buildSettingsByScheme;
 
   Future<XcodeProjectInfo> projectInfo() async {
-    if (!existsSync() || !globals.xcodeProjectInterpreter.isInstalled) {
+    if (!xcodeProject.existsSync() || !globals.xcodeProjectInterpreter.isInstalled) {
       return null;
     }
     return _projectInfo ??= await globals.xcodeProjectInterpreter.getInfo(hostAppRoot.path);
diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart
index de735a7..c67fb7d 100644
--- a/packages/flutter_tools/test/general.shard/project_test.dart
+++ b/packages/flutter_tools/test/general.shard/project_test.dart
@@ -332,6 +332,7 @@
 
       testWithMocks('from build settings, if no plist', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         when(mockXcodeProjectInterpreter.getBuildSettings(any, scheme: anyNamed('scheme'))).thenAnswer(
                 (_) {
               return Future<Map<String,String>>.value(<String, String>{
@@ -362,6 +363,7 @@
 
       testWithMocks('from build settings and plist, if default variable', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         when(mockXcodeProjectInterpreter.getBuildSettings(any, scheme: anyNamed('scheme'))).thenAnswer(
                 (_) {
               return Future<Map<String,String>>.value(<String, String>{
@@ -379,6 +381,7 @@
 
       testWithMocks('from build settings and plist, by substitution', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         project.ios.defaultHostInfoPlist.createSync(recursive: true);
         when(mockXcodeProjectInterpreter.getBuildSettings(any, scheme: anyNamed('scheme'))).thenAnswer(
           (_) {
@@ -398,6 +401,7 @@
 
       testWithMocks('fails with no flavor and defined schemes', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         when(mockXcodeProjectInterpreter.getInfo(any, projectFilename: anyNamed('projectFilename'))).thenAnswer( (_) {
           return Future<XcodeProjectInfo>.value(XcodeProjectInfo(<String>[], <String>[], <String>['free', 'paid'], logger));
         });
@@ -409,6 +413,7 @@
 
       testWithMocks('handles case insensitive flavor', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         when(mockXcodeProjectInterpreter.getBuildSettings(any, scheme: anyNamed('scheme'))).thenAnswer(
                 (_) {
               return Future<Map<String,String>>.value(<String, String>{
@@ -426,6 +431,7 @@
 
       testWithMocks('fails with flavor and default schemes', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         when(mockXcodeProjectInterpreter.getInfo(any, projectFilename: anyNamed('projectFilename'))).thenAnswer( (_) {
           return Future<XcodeProjectInfo>.value(XcodeProjectInfo(<String>[], <String>[], <String>['Runner'], logger));
         });
@@ -479,6 +485,7 @@
 
       testUsingContext('app product name xcodebuild settings', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         when(mockXcodeProjectInterpreter.getBuildSettings(any, scheme: anyNamed('scheme'))).thenAnswer((_) {
           return Future<Map<String,String>>.value(<String, String>{
             'FULL_PRODUCT_NAME': 'My App.app'
@@ -648,6 +655,7 @@
 
       testUsingContext('has watch companion', () async {
         final FlutterProject project = await someProject();
+        project.ios.xcodeProject.createSync();
         project.ios.hostAppRoot.childDirectory('WatchTarget').childFile('Info.plist').createSync(recursive: true);
         when(mockPlistUtils.getValueFromFile(any, 'WKCompanionAppBundleIdentifier')).thenReturn('io.flutter.someProject');