Migrate iOS project to Xcode 13 compatibility (#90304)
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/project_migrator.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/deployment_target_migration.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/project_base_configuration_migration.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/project_build_location_migration.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/project_object_version_migration.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embedding_migration.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
@@ -600,6 +601,113 @@ keep this 3
|
||||
expect('Updating minimum iOS deployment target from 8.0 to 9.0'.allMatches(testLogger.statusText).length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
group('update Xcode project object version', () {
|
||||
late MemoryFileSystem memoryFileSystem;
|
||||
late BufferLogger testLogger;
|
||||
late FakeIosProject project;
|
||||
late File xcodeProjectInfoFile;
|
||||
late File xcodeProjectSchemeFile;
|
||||
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem();
|
||||
testLogger = BufferLogger.test();
|
||||
project = FakeIosProject();
|
||||
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
||||
project.xcodeProjectInfoFile = xcodeProjectInfoFile;
|
||||
|
||||
xcodeProjectSchemeFile = memoryFileSystem.file('Runner.xcscheme');
|
||||
project.xcodeProjectSchemeFile = xcodeProjectSchemeFile;
|
||||
});
|
||||
|
||||
testWithoutContext('skipped if files are missing', () {
|
||||
final ProjectObjectVersionMigration iosProjectMigration = ProjectObjectVersionMigration(
|
||||
project,
|
||||
testLogger,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
expect(xcodeProjectInfoFile.existsSync(), isFalse);
|
||||
expect(xcodeProjectSchemeFile.existsSync(), isFalse);
|
||||
|
||||
expect(testLogger.traceText, contains('Xcode project not found, skipping Xcode compatibility migration'));
|
||||
expect(testLogger.traceText, contains('Runner scheme not found, skipping Xcode compatibility migration'));
|
||||
expect(testLogger.statusText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('skipped if nothing to upgrade', () {
|
||||
const String xcodeProjectInfoFileContents = '''
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1300;
|
||||
ORGANIZATIONNAME = "";
|
||||
''';
|
||||
xcodeProjectInfoFile.writeAsStringSync(xcodeProjectInfoFileContents);
|
||||
|
||||
const String xcodeProjectSchemeFileContents = '''
|
||||
LastUpgradeVersion = "1300"
|
||||
''';
|
||||
xcodeProjectSchemeFile.writeAsStringSync(xcodeProjectSchemeFileContents);
|
||||
|
||||
final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync();
|
||||
|
||||
final ProjectObjectVersionMigration iosProjectMigration = ProjectObjectVersionMigration(
|
||||
project,
|
||||
testLogger,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
|
||||
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
|
||||
expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents);
|
||||
expect(xcodeProjectSchemeFile.readAsStringSync(), xcodeProjectSchemeFileContents);
|
||||
|
||||
expect(testLogger.statusText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('Xcode project is migrated to Xcode 13', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1020;
|
||||
ORGANIZATIONNAME = "";
|
||||
''');
|
||||
|
||||
xcodeProjectSchemeFile.writeAsStringSync('''
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
''');
|
||||
|
||||
final ProjectObjectVersionMigration iosProjectMigration = ProjectObjectVersionMigration(
|
||||
project,
|
||||
testLogger,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
|
||||
expect(xcodeProjectInfoFile.readAsStringSync(), '''
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1300;
|
||||
ORGANIZATIONNAME = "";
|
||||
''');
|
||||
|
||||
expect(xcodeProjectSchemeFile.readAsStringSync(), '''
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1300"
|
||||
version = "1.3">
|
||||
''');
|
||||
// Only print once even though 3 lines were changed.
|
||||
expect('Updating project for Xcode compatibility'.allMatches(testLogger.statusText).length, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -613,6 +721,9 @@ class FakeIosProject extends Fake implements IosProject {
|
||||
@override
|
||||
File xcodeProjectInfoFile = MemoryFileSystem.test().file('xcodeProjectInfoFile');
|
||||
|
||||
@override
|
||||
File xcodeProjectSchemeFile = MemoryFileSystem.test().file('xcodeProjectSchemeFile');
|
||||
|
||||
@override
|
||||
File appFrameworkInfoPlist = MemoryFileSystem.test().file('appFrameworkInfoPlist');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user