appBundlePathsForDevice static method

List<String> appBundlePathsForDevice(
  1. String output,
  2. String udid
)

Distinct …app bundle paths for udid found in ps output. More than one means multiple apps share the sim — the caller treats that as ambiguous. Static + pure so it's unit-testable without a live ps.

Implementation

static List<String> appBundlePathsForDevice(String output, String udid) {
  final re = RegExp(
    '(/\\S*/CoreSimulator/Devices/$udid/data/Containers/'
    'Bundle/Application/[^/]+/[^/]+\\.app)',
  );
  final appPaths = <String>{};
  for (final line in output.split('\n')) {
    final appPath = re.firstMatch(line)?.group(1);
    if (appPath != null) appPaths.add(appPath);
  }
  return appPaths.toList();
}