setSimLocation function

Future<SimLocationResult> setSimLocation(
  1. SimLocationSetInput input
)

Sets a static GPS location on the iOS simulator.

Never throws; all error conditions are represented as sealed result cases.

Implementation

Future<SimLocationResult> setSimLocation(SimLocationSetInput input) async {
  final resolved = await resolveSimulatorDevice(deviceOverride: input.deviceOverride);
  if (resolved.error != null) {
    return SimLocationFailed(resolved.error!);
  }
  final device = resolved.udid!;
  final error = await runSimctl([
    'location',
    device,
    'set',
    '${input.latitude},${input.longitude}',
  ]);
  if (error != null) {
    return SimLocationFailed(error);
  }
  return SimLocationSet(latitude: input.latitude, longitude: input.longitude);
}