Build iOS apps using Swift Packages (#72761)
This commit is contained in:
@@ -5,10 +5,9 @@
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/project_migrator.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/remove_framework_link_and_embedding_migration.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart';
|
||||
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||
@@ -49,15 +48,7 @@ void main () {
|
||||
memoryFileSystem = MemoryFileSystem.test();
|
||||
mockXcode = MockXcode();
|
||||
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
||||
|
||||
testLogger = BufferLogger(
|
||||
terminal: AnsiTerminal(
|
||||
stdio: null,
|
||||
platform: const LocalPlatform(),
|
||||
),
|
||||
outputPreferences: OutputPreferences.test(),
|
||||
);
|
||||
|
||||
testLogger = BufferLogger.test();
|
||||
mockIosProject = MockIosProject();
|
||||
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
||||
});
|
||||
@@ -267,15 +258,7 @@ keep this 2
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem.test();
|
||||
xcodeWorkspaceSharedSettings = memoryFileSystem.file('WorkspaceSettings.xcsettings');
|
||||
|
||||
testLogger = BufferLogger(
|
||||
terminal: AnsiTerminal(
|
||||
stdio: null,
|
||||
platform: const LocalPlatform(),
|
||||
),
|
||||
outputPreferences: OutputPreferences.test(),
|
||||
);
|
||||
|
||||
testLogger = BufferLogger.test();
|
||||
mockIosProject = MockIosProject();
|
||||
when(mockIosProject.xcodeWorkspaceSharedSettings).thenReturn(xcodeWorkspaceSharedSettings);
|
||||
});
|
||||
@@ -338,6 +321,85 @@ keep this 2
|
||||
});
|
||||
});
|
||||
|
||||
group('Xcode default build location', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
BufferLogger testLogger;
|
||||
MockIosProject mockIosProject;
|
||||
File xcodeProjectWorkspaceData;
|
||||
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem();
|
||||
xcodeProjectWorkspaceData = memoryFileSystem.file('contents.xcworkspacedata');
|
||||
testLogger = BufferLogger.test();
|
||||
mockIosProject = MockIosProject();
|
||||
when(mockIosProject.xcodeProjectWorkspaceData).thenReturn(xcodeProjectWorkspaceData);
|
||||
});
|
||||
|
||||
testWithoutContext('skipped if files are missing', () {
|
||||
final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
expect(xcodeProjectWorkspaceData.existsSync(), isFalse);
|
||||
|
||||
expect(testLogger.traceText, contains('Xcode project workspace data not found, skipping build location migration.'));
|
||||
expect(testLogger.statusText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('skipped if nothing to upgrade', () {
|
||||
const String contents = '''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>''';
|
||||
xcodeProjectWorkspaceData.writeAsStringSync(contents);
|
||||
|
||||
final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
expect(xcodeProjectWorkspaceData.existsSync(), isTrue);
|
||||
expect(testLogger.statusText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('Xcode project is migrated', () {
|
||||
const String contents = '''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
''';
|
||||
xcodeProjectWorkspaceData.writeAsStringSync(contents);
|
||||
|
||||
final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
expect(xcodeProjectWorkspaceData.readAsStringSync(), '''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
''');
|
||||
expect(testLogger.statusText, contains('Upgrading contents.xcworkspacedata'));
|
||||
});
|
||||
});
|
||||
|
||||
group('remove Runner project base configuration', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
BufferLogger testLogger;
|
||||
@@ -345,17 +407,9 @@ keep this 2
|
||||
File xcodeProjectInfoFile;
|
||||
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem.test();
|
||||
memoryFileSystem = MemoryFileSystem();
|
||||
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
||||
|
||||
testLogger = BufferLogger(
|
||||
terminal: AnsiTerminal(
|
||||
stdio: null,
|
||||
platform: const LocalPlatform(),
|
||||
),
|
||||
outputPreferences: OutputPreferences.test(),
|
||||
);
|
||||
|
||||
testLogger = BufferLogger.test();
|
||||
mockIosProject = MockIosProject();
|
||||
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user