Unverified Commit 3477df74 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate iOS project migrations to null safety (#83855)

parent 14f00790
...@@ -21,7 +21,7 @@ abstract class ProjectMigrator { ...@@ -21,7 +21,7 @@ abstract class ProjectMigrator {
/// Return null if the line should be deleted. /// Return null if the line should be deleted.
@protected @protected
String migrateLine(String line) { String? migrateLine(String line) {
return line; return line;
} }
...@@ -41,7 +41,7 @@ abstract class ProjectMigrator { ...@@ -41,7 +41,7 @@ abstract class ProjectMigrator {
bool migrationRequired = false; bool migrationRequired = false;
for (final String line in lines) { for (final String line in lines) {
final String newProjectLine = migrateLine(line); final String? newProjectLine = migrateLine(line);
if (newProjectLine == null) { if (newProjectLine == null) {
logger.printTrace('Migrating $basename, removing:'); logger.printTrace('Migrating $basename, removing:');
logger.printTrace(' $line'); logger.printTrace(' $line');
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../base/logger.dart'; import '../../base/logger.dart';
import '../../base/project_migrator.dart'; import '../../base/project_migrator.dart';
...@@ -41,7 +39,7 @@ class ProjectBaseConfigurationMigration extends ProjectMigrator { ...@@ -41,7 +39,7 @@ class ProjectBaseConfigurationMigration extends ProjectMigrator {
multiLine: true, multiLine: true,
); );
final RegExpMatch match = projectBuildConfigurationList.firstMatch(originalProjectContents); final RegExpMatch? match = projectBuildConfigurationList.firstMatch(originalProjectContents);
// If the PBXProject "Runner" build configuration identifiers can't be parsed, default to the generated template identifiers. // If the PBXProject "Runner" build configuration identifiers can't be parsed, default to the generated template identifiers.
final String debugIdentifier = match?.group(1) ?? '97C147031CF9000F007C117D'; final String debugIdentifier = match?.group(1) ?? '97C147031CF9000F007C117D';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../base/logger.dart'; import '../../base/logger.dart';
import '../../base/project_migrator.dart'; import '../../base/project_migrator.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../../base/common.dart'; import '../../base/common.dart';
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../base/logger.dart'; import '../../base/logger.dart';
...@@ -39,7 +37,7 @@ class RemoveFrameworkLinkAndEmbeddingMigration extends ProjectMigrator { ...@@ -39,7 +37,7 @@ class RemoveFrameworkLinkAndEmbeddingMigration extends ProjectMigrator {
} }
@override @override
String migrateLine(String line) { String? migrateLine(String line) {
// App.framework Frameworks reference. // App.framework Frameworks reference.
// isa = PBXFrameworksBuildPhase; // isa = PBXFrameworksBuildPhase;
// files = ( // files = (
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../base/logger.dart'; import '../../base/logger.dart';
import '../../base/project_migrator.dart'; import '../../base/project_migrator.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -14,14 +12,13 @@ import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embed ...@@ -14,14 +12,13 @@ import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embed
import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart'; import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
void main () { void main () {
group('iOS migration', () { group('iOS migration', () {
TestUsage testUsage; late TestUsage testUsage;
setUp(() { setUp(() {
testUsage = TestUsage(); testUsage = TestUsage();
...@@ -40,10 +37,10 @@ void main () { ...@@ -40,10 +37,10 @@ void main () {
}); });
group('remove framework linking and embedding migration', () { group('remove framework linking and embedding migration', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
BufferLogger testLogger; late BufferLogger testLogger;
FakeIosProject project; late FakeIosProject project;
File xcodeProjectInfoFile; late File xcodeProjectInfoFile;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem.test(); memoryFileSystem = MemoryFileSystem.test();
...@@ -187,10 +184,10 @@ keep this 2 ...@@ -187,10 +184,10 @@ keep this 2
}); });
group('new Xcode build system', () { group('new Xcode build system', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
BufferLogger testLogger; late BufferLogger testLogger;
FakeIosProject project; late FakeIosProject project;
File xcodeWorkspaceSharedSettings; late File xcodeWorkspaceSharedSettings;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem.test(); memoryFileSystem = MemoryFileSystem.test();
...@@ -259,10 +256,10 @@ keep this 2 ...@@ -259,10 +256,10 @@ keep this 2
}); });
group('Xcode default build location', () { group('Xcode default build location', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
BufferLogger testLogger; late BufferLogger testLogger;
FakeIosProject project; late FakeIosProject project;
File xcodeProjectWorkspaceData; late File xcodeProjectWorkspaceData;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem(); memoryFileSystem = MemoryFileSystem();
...@@ -338,10 +335,10 @@ keep this 2 ...@@ -338,10 +335,10 @@ keep this 2
}); });
group('remove Runner project base configuration', () { group('remove Runner project base configuration', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
BufferLogger testLogger; late BufferLogger testLogger;
FakeIosProject project; late FakeIosProject project;
File xcodeProjectInfoFile; late File xcodeProjectInfoFile;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem(); memoryFileSystem = MemoryFileSystem();
...@@ -495,18 +492,18 @@ keep this 3 ...@@ -495,18 +492,18 @@ keep this 3
class FakeIosProject extends Fake implements IosProject { class FakeIosProject extends Fake implements IosProject {
@override @override
File xcodeProjectWorkspaceData; File xcodeProjectWorkspaceData = MemoryFileSystem.test().file('xcodeProjectWorkspaceData');
@override @override
File xcodeWorkspaceSharedSettings; File xcodeWorkspaceSharedSettings = MemoryFileSystem.test().file('xcodeWorkspaceSharedSettings');
@override @override
File xcodeProjectInfoFile; File xcodeProjectInfoFile = MemoryFileSystem.test().file('xcodeProjectInfoFile');
} }
class FakeIOSMigrator extends ProjectMigrator { class FakeIOSMigrator extends ProjectMigrator {
FakeIOSMigrator({@required this.succeeds}) FakeIOSMigrator({required this.succeeds})
: super(null); : super(BufferLogger.test());
final bool succeeds; final bool succeeds;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment