diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 4458ff98e9..fd4c56c54f 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -8,10 +8,13 @@ import '../android/android.dart' as android; import '../base/common.dart'; import '../base/file_system.dart'; import '../base/utils.dart'; +import '../build_info.dart'; import '../cache.dart'; import '../dart/pub.dart'; import '../doctor.dart'; +import '../flx.dart' as flx; import '../globals.dart'; +import '../ios/xcodeproj.dart'; import '../runner/flutter_command.dart'; import '../template.dart'; @@ -98,9 +101,10 @@ class CreateCommand extends FlutterCommand { renderDriverTest: argResults['with-driver-test'] ); printStatus('Wrote $generatedCount files.'); - printStatus(''); + updateXcodeGeneratedProperties(dirPath, BuildMode.debug, flx.defaultMainPath); + if (argResults['pub']) await pubGet(directory: dirPath); diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 16a0aecc15..245b335cdc 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -20,8 +20,7 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t localsBuffer.writeln('FLUTTER_ROOT=$flutterRoot'); // This holds because requiresProjectRoot is true for this command - String applicationRoot = fs.path.normalize(fs.currentDirectory.path); - localsBuffer.writeln('FLUTTER_APPLICATION_PATH=$applicationRoot'); + localsBuffer.writeln('FLUTTER_APPLICATION_PATH=${fs.path.normalize(projectPath)}'); // Relative to FLUTTER_APPLICATION_PATH, which is [Directory.current]. localsBuffer.writeln('FLUTTER_TARGET=$target'); diff --git a/packages/flutter_tools/test/create_test.dart b/packages/flutter_tools/test/create_test.dart index ddff7801e2..6c9ffedecc 100644 --- a/packages/flutter_tools/test/create_test.dart +++ b/packages/flutter_tools/test/create_test.dart @@ -66,6 +66,15 @@ void main() { expect(original, formatted, reason: file.path); } } + + // Generated Xcode settings + String xcodeConfigPath = fs.path.join('ios', 'Flutter', 'Generated.xcconfig'); + expectExists(xcodeConfigPath); + File xcodeConfigFile = fs.file(fs.path.join(temp.path, xcodeConfigPath)); + String xcodeConfig = xcodeConfigFile.readAsStringSync(); + expect(xcodeConfig, contains('FLUTTER_ROOT=')); + expect(xcodeConfig, contains('FLUTTER_APPLICATION_PATH=')); + expect(xcodeConfig, contains('FLUTTER_FRAMEWORK_DIR=')); }); // Verify that we can regenerate over an existing project.