Add lldb init file (#164344)

Adds an .lldbinit file to iOS app xcscheme.

Adding to scheme files can be error prone since a developer may be using
custom schemes (flavors). If we can't add it to the scheme, we print an
error without failing.

Since it is part of the scheme, it will be added to the project and will
be used on every run regardless of the device type/version. The Dart
side handles limiting to specific devices. If needed, we can alter the
.lldbinit file during `flutter assemble` to rewrite it since it doesn't
read the file until launch time (therefore it can be changed during
build time).

During `flutter assemble`, if the project doesn't have an LLDB Init File
set for any schemes, it'll throw an error if running in debug mode with
an iOS 18.4+ device.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Victoria Ashworth
2025-03-06 15:21:52 -06:00
committed by GitHub
parent 8876bccf3a
commit eb07c51230
19 changed files with 1935 additions and 8 deletions

View File

@@ -1152,6 +1152,100 @@ void main() {
expect(processManager, hasNoRemainingExpectations);
});
});
group('DebugIosLLDBInit', () {
testUsingContext(
'throws error if missing LLDB Init File in all schemes',
() async {
const String projectPath = 'path/to/project';
fileSystem.directory(projectPath).createSync(recursive: true);
environment.defines[kIosArchs] = 'arm64';
environment.defines[kSdkRoot] = 'path/to/iPhoneOS.sdk';
environment.defines[kBuildMode] = 'debug';
environment.defines[kSrcRoot] = projectPath;
environment.defines[kTargetDeviceOSVersion] = '18.4.1';
expect(
const DebugIosLLDBInit().build(environment),
throwsToolExit(
message: 'Debugging Flutter on new iOS versions requires an LLDB Init File.',
),
);
},
overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => macPlatform,
},
);
testUsingContext(
'skips if targetting simulator',
() async {
const String projectPath = 'path/to/project';
fileSystem.directory(projectPath).createSync(recursive: true);
environment.defines[kIosArchs] = 'arm64';
environment.defines[kSdkRoot] = 'path/to/iPhoneSimulator.sdk';
environment.defines[kBuildMode] = 'debug';
environment.defines[kSrcRoot] = projectPath;
environment.defines[kTargetDeviceOSVersion] = '18.4.1';
await const DebugIosLLDBInit().build(environment);
},
overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => macPlatform,
},
);
testUsingContext(
'skips if iOS version is less than 18.4',
() async {
const String projectPath = 'path/to/project';
fileSystem.directory(projectPath).createSync(recursive: true);
environment.defines[kIosArchs] = 'arm64';
environment.defines[kSdkRoot] = 'path/to/iPhoneOS.sdk';
environment.defines[kBuildMode] = 'debug';
environment.defines[kSrcRoot] = projectPath;
environment.defines[kTargetDeviceOSVersion] = '18.3.1';
await const DebugIosLLDBInit().build(environment);
},
overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => macPlatform,
},
);
testUsingContext(
'does not throw error if there is an LLDB Init File in any scheme',
() async {
const String projectPath = 'path/to/project';
fileSystem.directory(projectPath).createSync(recursive: true);
fileSystem
.directory(projectPath)
.childDirectory('MyProject.xcodeproj')
.childDirectory('xcshareddata')
.childDirectory('xcschemes')
.childFile('MyProject.xcscheme')
..createSync(recursive: true)
..writeAsStringSync(r'customLLDBInitFile = "some/path/.lldbinit"');
environment.defines[kIosArchs] = 'arm64';
environment.defines[kSdkRoot] = 'path/to/iPhoneOS.sdk';
environment.defines[kBuildMode] = 'debug';
environment.defines[kSrcRoot] = projectPath;
await const DebugIosLLDBInit().build(environment);
},
overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => macPlatform,
},
);
});
}
class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterpreter {

View File

@@ -808,6 +808,7 @@ void main() {
testUsingContext(
'succeeds',
() async {
const String flavor = 'free';
final IOSDevice iosDevice = setUpIOSDevice(
fileSystem: fileSystem,
processManager: FakeProcessManager.any(),
@@ -817,7 +818,7 @@ void main() {
coreDeviceControl: FakeIOSCoreDeviceControl(),
xcodeDebug: FakeXcodeDebug(
expectedProject: XcodeDebugProject(
scheme: 'free',
scheme: flavor,
xcodeWorkspace: fileSystem.directory('/ios/Runner.xcworkspace'),
xcodeProject: fileSystem.directory('/ios/Runner.xcodeproj'),
hostAppProjectName: 'Runner',
@@ -825,11 +826,11 @@ void main() {
expectedDeviceId: '123',
expectedLaunchArguments: <String>['--enable-dart-profiling'],
expectedSchemeFilePath:
'/ios/Runner.xcodeproj/xcshareddata/xcschemes/free.xcscheme',
'/ios/Runner.xcodeproj/xcshareddata/xcschemes/$flavor.xcscheme',
),
);
setUpIOSProject(fileSystem);
setUpIOSProject(fileSystem, scheme: flavor);
final FlutterProject flutterProject = FlutterProject.fromDirectory(
fileSystem.currentDirectory,
);
@@ -1156,7 +1157,11 @@ void main() {
});
}
void setUpIOSProject(FileSystem fileSystem, {bool createWorkspace = true}) {
void setUpIOSProject(
FileSystem fileSystem, {
bool createWorkspace = true,
String scheme = 'Runner',
}) {
fileSystem.file('pubspec.yaml').writeAsStringSync('''
name: my_app
''');
@@ -1166,6 +1171,10 @@ name: my_app
fileSystem.directory('ios/Runner.xcworkspace').createSync();
}
fileSystem.file('ios/Runner.xcodeproj/project.pbxproj').createSync(recursive: true);
final File schemeFile = fileSystem.file(
'ios/Runner.xcodeproj/xcshareddata/xcschemes/$scheme.xcscheme',
)..createSync(recursive: true);
schemeFile.writeAsStringSync(_validScheme);
// This is the expected output directory.
fileSystem.directory('build/ios/iphoneos/My Super Awesome App.app').createSync(recursive: true);
}
@@ -1330,3 +1339,69 @@ class FakeIOSCoreDeviceControl extends Fake implements IOSCoreDeviceControl {
return launchSuccess;
}
}
const String _validScheme = '''
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "331C8080294A63A400263BE5"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction>
</ProfileAction>
<AnalyzeAction>
</AnalyzeAction>
<ArchiveAction>
</ArchiveAction>
</Scheme>
''';

View File

@@ -0,0 +1,692 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/migrations/lldb_init_migration.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
void main() {
group('LLDBInitMigration', () {
testWithoutContext('fails if Xcode project is not found', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Xcode project not found'));
});
group('get scheme file', () {
testWithoutContext('fails if Xcode project info not found', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project._projectInfo = null;
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Unable to get Xcode project info.'));
});
testWithoutContext('fails if Xcode workspace not found', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeWorkspace = null;
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Xcode workspace not found.'));
});
testWithoutContext('fails if scheme not found', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project._projectInfo = XcodeProjectInfo(<String>[], <String>[], <String>[], testLogger);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(
testLogger.errorText,
contains('You must specify a --flavor option to select one of the available schemes.'),
);
});
testWithoutContext('fails if scheme file not found', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project, createSchemeFile: false);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Unable to get scheme file for Runner.'));
});
});
testWithoutContext('does nothing if both Launch and Test are already migrated', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(
lldbInitFile:
'\n customLLDBInitFile = "\$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"',
),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, isEmpty);
});
testWithoutContext('prints error if only Launch action is migrated', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(
lldbInitFile:
'\n customLLDBInitFile = "\$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"',
testLLDBInitFile: '',
),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(
testLogger.errorText,
contains(
'Running Flutter in debug mode on new iOS versions requires a LLDB '
'Init File, but the Test action in the Runner scheme does not have it set.',
),
);
});
testWithoutContext('prints error if only Test action is migrated', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(
testLLDBInitFile:
'\n customLLDBInitFile = "\$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"',
),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(
testLogger.errorText,
contains(
'Running Flutter in debug mode on new iOS versions requires a LLDB '
'Init File, but the Launch action in the Runner scheme does not have it set.',
),
);
});
testWithoutContext(
'print error if customLLDBInitFile already exists and does not contain flutter lldbinit',
() async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(lldbInitFile: '\n customLLDBInitFile = "non_flutter/.lldbinit"'),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(
testLogger.errorText,
contains('Running Flutter in debug mode on new iOS versions requires a LLDB Init File'),
);
},
);
testWithoutContext(
'skips if customLLDBInitFile already exists and contain flutter lldbinit',
() async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
memoryFileSystem.file('non_flutter/.lldbinit')
..createSync(recursive: true)
..writeAsStringSync('command source /path/to/Flutter/ephemeral/flutter_lldbinit');
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(lldbInitFile: '\n customLLDBInitFile = "non_flutter/.lldbinit"'),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, isEmpty);
},
);
testWithoutContext(
'prints error if customLLDBInitFile already exists and not both Launch and Test contain flutter lldbinit',
() async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
memoryFileSystem.file('non_flutter/.lldbinit')
..createSync(recursive: true)
..writeAsStringSync('command source /path/to/Flutter/ephemeral/flutter_lldbinit');
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(
lldbInitFile: '\n customLLDBInitFile = "non_flutter/.lldbinit"',
testLLDBInitFile: '\n customLLDBInitFile = "non_flutter/.test_lldbinit"',
),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(
testLogger.errorText,
contains('Running Flutter in debug mode on new iOS versions requires a LLDB Init File'),
);
},
);
testWithoutContext(
'parses customLLDBInitFile if already exists and replaces Xcode build settings',
() async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
buildSettings: <String, String>{'SRCROOT': 'src_root'},
);
_createProjectFiles(project);
memoryFileSystem.file('src_root/non_flutter/.lldbinit')
..createSync(recursive: true)
..writeAsStringSync('command source /path/to/Flutter/ephemeral/flutter_lldbinit');
project.xcodeProjectSchemeFile().writeAsStringSync(
_validScheme(
lldbInitFile: '\n customLLDBInitFile = "\$(SRCROOT)/non_flutter/.lldbinit"',
),
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, isEmpty);
},
);
testWithoutContext('prints error if LaunchAction is missing', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(_missingLaunchAction);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Failed to find LaunchAction for the Scheme'));
});
testWithoutContext('prints error if TestAction is missing', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(_missingTestAction);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Failed to find TestAction for the Scheme'));
});
testWithoutContext('prints error if scheme file is invalid XML', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(
'${_validScheme()} <an opening without a close>',
);
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, contains('Failed to parse'));
});
testWithoutContext('succeeds', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final FakeXcodeProject project = FakeXcodeProject(
platform: SupportedPlatform.ios.name,
fileSystem: memoryFileSystem,
logger: testLogger,
);
_createProjectFiles(project);
project.xcodeProjectSchemeFile().writeAsStringSync(_validScheme());
final LLDBInitMigration migration = LLDBInitMigration(
project,
BuildInfo.debug,
testLogger,
environmentType: EnvironmentType.physical,
fileSystem: memoryFileSystem,
);
await migration.migrate();
expect(testLogger.errorText, isEmpty);
expect(
project.xcodeProjectSchemeFile().readAsStringSync(),
_validScheme(
lldbInitFile:
'\n customLLDBInitFile = "\$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"',
),
);
});
});
}
void _createProjectFiles(FakeXcodeProject project, {bool createSchemeFile = true, String? scheme}) {
project.parent.directory.createSync(recursive: true);
project.hostAppRoot.createSync(recursive: true);
project.xcodeProjectInfoFile.createSync(recursive: true);
if (createSchemeFile) {
project.xcodeProjectSchemeFile(scheme: scheme).createSync(recursive: true);
project.xcodeProjectSchemeFile().writeAsStringSync(_validScheme());
}
}
String _validScheme({String lldbInitFile = '', String? testLLDBInitFile}) {
testLLDBInitFile ??= lldbInitFile;
return '''
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"$testLLDBInitFile
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "331C8080294A63A400263BE5"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"$lldbInitFile
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction>
</ProfileAction>
<AnalyzeAction>
</AnalyzeAction>
<ArchiveAction>
</ArchiveAction>
</Scheme>
''';
}
const String _missingTestAction = '''
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction>
</BuildAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction>
</ProfileAction>
<AnalyzeAction>
</AnalyzeAction>
<ArchiveAction>
</ArchiveAction>
</Scheme>
''';
const String _missingLaunchAction = '''
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "331C8080294A63A400263BE5"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<ProfileAction>
</ProfileAction>
<AnalyzeAction>
</AnalyzeAction>
<ArchiveAction>
</ArchiveAction>
</Scheme>
''';
class FakeFlutterProject extends Fake implements FlutterProject {
FakeFlutterProject({required MemoryFileSystem fileSystem})
: directory = fileSystem.directory('app_name');
@override
Directory directory;
}
class FakeXcodeProject extends Fake implements IosProject {
FakeXcodeProject({
required MemoryFileSystem fileSystem,
required String platform,
required this.logger,
this.buildSettings,
}) : hostAppRoot = fileSystem.directory('app_name').childDirectory(platform),
parent = FakeFlutterProject(fileSystem: fileSystem);
final Logger logger;
late XcodeProjectInfo? _projectInfo = XcodeProjectInfo(
<String>['Runner'],
<String>['Debug', 'Release', 'Profile'],
<String>['Runner'],
logger,
);
Map<String, String>? buildSettings;
@override
Directory hostAppRoot;
@override
FakeFlutterProject parent;
@override
Directory get xcodeProject => hostAppRoot.childDirectory('$hostAppProjectName.xcodeproj');
@override
File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');
@override
late Directory? xcodeWorkspace = hostAppRoot.childDirectory('$hostAppProjectName.xcworkspace');
@override
String hostAppProjectName = 'Runner';
@override
File get lldbInitFile => hostAppRoot
.childDirectory('Flutter')
.childDirectory('ephemeral')
.childFile('flutter_lldbinit');
@override
Future<XcodeProjectInfo?> projectInfo() async {
return _projectInfo;
}
@override
File xcodeProjectSchemeFile({String? scheme}) {
final String schemeName = scheme ?? 'Runner';
return xcodeProject
.childDirectory('xcshareddata')
.childDirectory('xcschemes')
.childFile('$schemeName.xcscheme');
}
@override
Future<Map<String, String>?> buildSettingsForBuildInfo(
BuildInfo? buildInfo, {
String? scheme,
String? configuration,
String? target,
EnvironmentType environmentType = EnvironmentType.physical,
String? deviceId,
bool isWatch = false,
}) async {
return buildSettings;
}
}

View File

@@ -54,6 +54,8 @@ void main() {
'--ExtraGenSnapshotOptions=',
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'debug_ios_bundle_flutter_assets',
],
),
@@ -101,6 +103,8 @@ void main() {
'--ExtraGenSnapshotOptions=',
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'debug_ios_bundle_flutter_assets',
],
),
@@ -133,6 +137,8 @@ void main() {
const String splitDebugInfo = '/path/to/split/debug/info';
const String trackWidgetCreation = 'true';
const String treeShake = 'true';
const String srcRoot = '/path/to/project';
const String iOSVersion = '18.3.1';
final TestContext context = TestContext(
<String>['build'],
<String, String>{
@@ -154,6 +160,8 @@ void main() {
'SPLIT_DEBUG_INFO': splitDebugInfo,
'TRACK_WIDGET_CREATION': trackWidgetCreation,
'TREE_SHAKE_ICONS': treeShake,
'SRCROOT': srcRoot,
'TARGET_DEVICE_OS_VERSION': iOSVersion,
},
commands: <FakeCommand>[
FakeCommand(
@@ -178,6 +186,8 @@ void main() {
'--ExtraGenSnapshotOptions=$extraGenSnapshotOptions',
'--DartDefines=$dartDefines',
'--ExtraFrontEndOptions=$extraFrontEndOptions',
'-dSrcRoot=$srcRoot',
'-dTargetDeviceOSVersion=$iOSVersion',
'-dCodesignIdentity=$expandedCodeSignIdentity',
'release_ios_bundle_flutter_assets',
],
@@ -251,6 +261,8 @@ void main() {
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dPreBuildAction=PrepareFramework',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'debug_unpack_ios',
],
),
@@ -298,6 +310,8 @@ void main() {
'--ExtraGenSnapshotOptions=',
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'-dPreBuildAction=PrepareFramework',
'debug_unpack_ios',
],
@@ -326,6 +340,8 @@ void main() {
const String splitDebugInfo = '/path/to/split/debug/info';
const String trackWidgetCreation = 'true';
const String treeShake = 'true';
const String srcRoot = '/path/to/project';
const String iOSVersion = '18.3.1';
final TestContext context = TestContext(
<String>['prepare'],
<String, String>{
@@ -347,6 +363,8 @@ void main() {
'SPLIT_DEBUG_INFO': splitDebugInfo,
'TRACK_WIDGET_CREATION': trackWidgetCreation,
'TREE_SHAKE_ICONS': treeShake,
'SRCROOT': srcRoot,
'TARGET_DEVICE_OS_VERSION': iOSVersion,
},
commands: <FakeCommand>[
FakeCommand(
@@ -371,6 +389,8 @@ void main() {
'--ExtraGenSnapshotOptions=$extraGenSnapshotOptions',
'--DartDefines=$dartDefines',
'--ExtraFrontEndOptions=$extraFrontEndOptions',
'-dSrcRoot=$srcRoot',
'-dTargetDeviceOSVersion=$iOSVersion',
'-dPreBuildAction=PrepareFramework',
'-dCodesignIdentity=$expandedCodeSignIdentity',
'release_unpack_ios',
@@ -422,6 +442,8 @@ void main() {
'--ExtraGenSnapshotOptions=',
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'-dPreBuildAction=PrepareFramework',
'debug_unpack_ios',
],
@@ -473,6 +495,8 @@ void main() {
'--ExtraGenSnapshotOptions=',
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'-dPreBuildAction=PrepareFramework',
'debug_unpack_ios',
],
@@ -523,6 +547,8 @@ void main() {
'--ExtraGenSnapshotOptions=',
'--DartDefines=',
'--ExtraFrontEndOptions=',
'-dSrcRoot=',
'-dTargetDeviceOSVersion=',
'-dPreBuildAction=PrepareFramework',
'debug_unpack_ios',
],

View File

@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/version.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/flutter_manifest.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
@@ -76,6 +77,21 @@ void main() {
expect(project.xcodeConfigFor('Debug').path, 'app_name/ios/Flutter/Debug.xcconfig');
});
testWithoutContext('lldbInitFile', () {
final MemoryFileSystem fs = MemoryFileSystem.test();
final IosProject project = IosProject.fromFlutter(FakeFlutterProject(fileSystem: fs));
expect(project.lldbInitFile.path, 'app_name/ios/Flutter/ephemeral/flutter_lldbinit');
});
testWithoutContext('lldbHelperPythonFile', () {
final MemoryFileSystem fs = MemoryFileSystem.test();
final IosProject project = IosProject.fromFlutter(FakeFlutterProject(fileSystem: fs));
expect(
project.lldbHelperPythonFile.path,
'app_name/ios/Flutter/ephemeral/flutter_lldb_helper.py',
);
});
group('projectInfo', () {
testUsingContext(
'is null if XcodeProjectInterpreter is null',
@@ -315,6 +331,110 @@ void main() {
},
);
});
group('ensureReadyForPlatformSpecificTooling', () {
group('lldb files are generated', () {
testUsingContext(
'when they are missing',
() async {
final MemoryFileSystem fs = MemoryFileSystem.test();
final Directory projectDirectory = fs.directory('path');
projectDirectory.childDirectory('ios').createSync(recursive: true);
final FlutterManifest manifest = FakeFlutterManifest();
final FlutterProject flutterProject = FlutterProject(
projectDirectory,
manifest,
manifest,
);
final IosProject project = IosProject.fromFlutter(flutterProject);
expect(project.lldbInitFile, isNot(exists));
expect(project.lldbHelperPythonFile, isNot(exists));
await project.ensureReadyForPlatformSpecificTooling();
expect(project.lldbInitFile, exists);
expect(project.lldbHelperPythonFile, exists);
},
overrides: <Type, Generator>{Cache: () => FakeCache(olderThanToolsStamp: true)},
);
testUsingContext(
'when they are older than tool',
() async {
final MemoryFileSystem fs = MemoryFileSystem.test();
final Directory projectDirectory = fs.directory('path');
projectDirectory.childDirectory('ios').createSync(recursive: true);
final FlutterManifest manifest = FakeFlutterManifest();
final FlutterProject flutterProject = FlutterProject(
projectDirectory,
manifest,
manifest,
);
final IosProject project = IosProject.fromFlutter(flutterProject);
project.lldbInitFile.createSync(recursive: true);
project.lldbInitFile.writeAsStringSync('old');
project.lldbHelperPythonFile.createSync(recursive: true);
project.lldbHelperPythonFile.writeAsStringSync('old');
await project.ensureReadyForPlatformSpecificTooling();
expect(
project.lldbInitFile.readAsStringSync(),
contains('Generated file, do not edit.'),
);
expect(
project.lldbHelperPythonFile.readAsStringSync(),
contains('Generated file, do not edit.'),
);
},
overrides: <Type, Generator>{Cache: () => FakeCache(olderThanToolsStamp: true)},
);
group('with a warning', () {
late BufferLogger testLogger;
late MemoryFileSystem fs;
late FakeCache cache;
setUp(() {
testLogger = BufferLogger.test();
fs = MemoryFileSystem.test();
cache = FakeCache();
});
testUsingContext(
'when the project is a module',
() async {
final Directory projectDirectory = fs.directory('path');
projectDirectory.childDirectory('ios').createSync(recursive: true);
final FlutterManifest manifest = FakeFlutterManifest(isModule: true);
final FlutterProject flutterProject = FlutterProject(
projectDirectory,
manifest,
manifest,
);
final IosProject project = IosProject.fromFlutter(flutterProject);
cache.filesOlderThanToolsStamp[project.lldbInitFile.basename] = true;
await project.ensureReadyForPlatformSpecificTooling();
expect(project.lldbInitFile, exists);
expect(project.lldbHelperPythonFile, exists);
expect(
testLogger.warningText,
contains('Debugging Flutter on new iOS versions requires an LLDB Init File'),
);
},
overrides: <Type, Generator>{
Cache: () => cache,
Logger: () => testLogger,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
FileSystemUtils: () => FakeFileSystemUtils(),
},
);
});
});
});
});
group('MacOSProject', () {
@@ -461,6 +581,9 @@ class FakeFlutterProject extends Fake implements FlutterProject {
@override
bool isModule = false;
@override
FlutterManifest get manifest => FakeFlutterManifest();
}
class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterpreter {
@@ -492,4 +615,42 @@ class FakeFlutterManifest extends Fake implements FlutterManifest {
@override
bool isModule;
@override
String? buildName;
@override
String? buildNumber;
@override
String? get iosBundleIdentifier => null;
@override
String get appName => '';
}
class FakeCache extends Fake implements Cache {
FakeCache({this.olderThanToolsStamp = false});
bool olderThanToolsStamp;
Map<String, bool> filesOlderThanToolsStamp = <String, bool>{};
@override
bool isOlderThanToolsStamp(FileSystemEntity entity) {
if (filesOlderThanToolsStamp.containsKey(entity.basename)) {
return filesOlderThanToolsStamp[entity.basename]!;
}
return olderThanToolsStamp;
}
}
class FakeFileSystemUtils extends Fake implements FileSystemUtils {
FakeFileSystemUtils({this.olderThanReference = false});
bool olderThanReference;
@override
bool isOlderThanReference({required FileSystemEntity entity, required File referenceFile}) {
return olderThanReference;
}
}

View File

@@ -0,0 +1,307 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/error_handling_io.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import '../src/common.dart';
import 'test_utils.dart';
void main() {
const String customLLDBInitFileSchemeSetting =
r'customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"';
test(
'Ensure lldb is added to Xcode project',
() async {
final Directory workingDirectory = fileSystem.systemTempDirectory.createTempSync(
'lldb_test.',
);
try {
final String workingDirectoryPath = workingDirectory.path;
const String appName = 'lldb_test';
final ProcessResult createResult = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'create',
'--org',
'io.flutter.devicelab',
'-i',
'swift',
appName,
'--platforms=ios',
], workingDirectory: workingDirectory.path);
expect(
createResult.exitCode,
0,
reason:
'Failed to create app: \n'
'stdout: \n${createResult.stdout}\n'
'stderr: \n${createResult.stderr}\n',
);
final String appDirectoryPath = fileSystem.path.join(workingDirectoryPath, appName);
final File schemeFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Runner.xcodeproj')
.childDirectory('xcshareddata')
.childDirectory('xcschemes')
.childFile('Runner.xcscheme');
expect(schemeFile.existsSync(), isTrue);
// Remove customLLDBInitFile from the scheme so we can validate it
// gets re-added if missing.
expect(schemeFile.readAsStringSync(), contains(customLLDBInitFileSchemeSetting));
schemeFile.writeAsStringSync(
schemeFile.readAsStringSync().replaceAll(customLLDBInitFileSchemeSetting, ''),
);
final File lldbInitFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Flutter')
.childDirectory('ephemeral')
.childFile('flutter_lldbinit');
expect(lldbInitFile.existsSync(), isTrue);
final File lldbPythonFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Flutter')
.childDirectory('ephemeral')
.childFile('flutter_lldb_helper.py');
expect(lldbPythonFile.existsSync(), isTrue);
// Delete LLDB files so we can verify they get re-added if missing.
lldbInitFile.deleteSync();
lldbPythonFile.deleteSync();
final ProcessResult buildResult = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
], workingDirectory: appDirectoryPath);
expect(
buildResult.exitCode,
0,
reason:
'Failed to build the app: \n'
'stdout: \n${buildResult.stdout}\n'
'stderr: \n${buildResult.stderr}\n',
);
expect(schemeFile.readAsStringSync(), contains(customLLDBInitFileSchemeSetting));
expect(lldbInitFile.existsSync(), isTrue);
expect(lldbPythonFile.existsSync(), isTrue);
} finally {
ErrorHandlingFileSystem.deleteIfExists(workingDirectory, recursive: true);
}
},
skip: !platform.isMacOS, // [intended] Can only build on macOS.
);
test(
'Ensure lldb is added to Xcode project when using flavor',
() async {
final Directory workingDirectory = fileSystem.systemTempDirectory.createTempSync(
'lldb_test.',
);
try {
final String workingDirectoryPath = workingDirectory.path;
const String appName = 'lldb_test';
const String flavor = 'vanilla';
final ProcessResult createResult = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'create',
'--org',
'io.flutter.devicelab',
'-i',
'swift',
appName,
'--platforms=ios',
], workingDirectory: workingDirectory.path);
expect(
createResult.exitCode,
0,
reason:
'Failed to create app: \n'
'stdout: \n${createResult.stdout}\n'
'stderr: \n${createResult.stderr}\n',
);
final String appDirectoryPath = fileSystem.path.join(workingDirectoryPath, appName);
final File schemeFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Runner.xcodeproj')
.childDirectory('xcshareddata')
.childDirectory('xcschemes')
.childFile('Runner.xcscheme');
expect(schemeFile.existsSync(), isTrue);
final File pbxprojFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Runner.xcodeproj')
.childFile('project.pbxproj');
expect(pbxprojFile.existsSync(), isTrue);
// Create flavor
final File flavorSchemeFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Runner.xcodeproj')
.childDirectory('xcshareddata')
.childDirectory('xcschemes')
.childFile('$flavor.xcscheme');
flavorSchemeFile.createSync(recursive: true);
flavorSchemeFile.writeAsStringSync(schemeFile.readAsStringSync());
String pbxprojContents = pbxprojFile.readAsStringSync();
pbxprojContents = pbxprojContents.replaceAll('97C147071CF9000F007C117D /* Release */,', '''
97C147071CF9000F007C117D /* Release */,
78624EC12D71262400FF7985 /* Release-vanilla */,
''');
pbxprojContents = pbxprojContents.replaceAll('97C147041CF9000F007C117D /* Release */,', '''
97C147041CF9000F007C117D /* Release */,
78624EC02D71262400FF7985 /* Release-vanilla */,
''');
pbxprojContents = pbxprojContents.replaceAll(
'/* Begin XCBuildConfiguration section */',
r'''
/* Begin XCBuildConfiguration section */
78624EC12D71262400FF7985 /* Release-vanilla */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.lldb_test;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = "Release-vanilla";
};
78624EC02D71262400FF7985 /* Release-vanilla */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = "Release-vanilla";
};
''',
);
pbxprojFile.writeAsStringSync(pbxprojContents);
// Remove customLLDBInitFile from the flavor's scheme so we can validate
// it gets re-added later.
expect(flavorSchemeFile.readAsStringSync(), contains(customLLDBInitFileSchemeSetting));
flavorSchemeFile.writeAsStringSync(
flavorSchemeFile.readAsStringSync().replaceAll(customLLDBInitFileSchemeSetting, ''),
);
final ProcessResult buildResult = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
'--flavor',
flavor,
], workingDirectory: appDirectoryPath);
expect(
buildResult.exitCode,
0,
reason:
'Failed to build config for the app: \n'
'stdout: \n${buildResult.stdout}\n'
'stderr: \n${buildResult.stderr}\n',
);
expect(flavorSchemeFile.readAsStringSync(), contains(customLLDBInitFileSchemeSetting));
final File lldbInitFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Flutter')
.childDirectory('ephemeral')
.childFile('flutter_lldbinit');
expect(lldbInitFile.existsSync(), isTrue);
final File lldbPythonFile = fileSystem
.directory(appDirectoryPath)
.childDirectory('ios')
.childDirectory('Flutter')
.childDirectory('ephemeral')
.childFile('flutter_lldb_helper.py');
expect(lldbPythonFile.existsSync(), isTrue);
} finally {
ErrorHandlingFileSystem.deleteIfExists(workingDirectory, recursive: true);
}
},
skip: !platform.isMacOS, // [intended] Can only build on macOS.
);
}