Pass 'build ios' device ID into xcodebuild (#96669)

This commit is contained in:
Jenn Magder 2022-01-19 10:20:11 -08:00 committed by GitHub
parent 25b2edbda0
commit 114185f686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -269,6 +269,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
codesign: shouldCodesign,
configOnly: configOnly,
buildAction: xcodeBuildAction,
deviceID: globals.deviceManager?.specifiedDeviceId,
);
if (!result.success) {

View File

@ -112,7 +112,13 @@ void main() {
// Creates a FakeCommand for the xcodebuild call to build the app
// in the given configuration.
FakeCommand _setUpFakeXcodeBuildHandler({ bool verbose = false, bool simulator = false, int exitCode = 0, void Function() onRun }) {
FakeCommand _setUpFakeXcodeBuildHandler({
bool verbose = false,
bool simulator = false,
String deviceId,
int exitCode = 0,
void Function() onRun,
}) {
return FakeCommand(
command: <String>[
'xcrun',
@ -132,10 +138,16 @@ void main() {
'-sdk',
if (simulator) ...<String>[
'iphonesimulator',
] else ...<String>[
'iphoneos',
],
if (deviceId != null) ...<String>[
'-destination',
'id=$deviceId',
] else if (simulator) ...<String>[
'-destination',
'generic/platform=iOS Simulator',
] else ...<String>[
'iphoneos',
'-destination',
'generic/platform=iOS',
],
@ -220,6 +232,27 @@ void main() {
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
});
testUsingContext('ios build invokes xcode build with device ID', () async {
final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles();
await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub', '--device-id', '1234']
);
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand,
_setUpFakeXcodeBuildHandler(deviceId: '1234', onRun: () {
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
}),
_setUpRsyncCommand(),
]),
Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
});
testUsingContext('ios simulator build invokes xcode build', () async {
final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles();