run static method

Future<String> run({
  1. required String projectRoot,
  2. required String command,
  3. required String ipaOutputPath,
  4. required String version,
  5. required String buildNumber,
  6. required String exportOptionsPath,
  7. String? flavor,
  8. ProcessRunner processRunner = const SystemProcessRunner(),
})

Runs the project-owned command with managed Apple build arguments.

The consumer must install the command's Flutter/FVM toolchain. This appends immutable version, build number, export-options, and optional flavor arguments, then validates ipaOutputPath.

Implementation

static Future<String> run({
  required String projectRoot,
  required String command,
  required String ipaOutputPath,
  required String version,
  required String buildNumber,
  required String exportOptionsPath,
  String? flavor,
  ProcessRunner processRunner = const SystemProcessRunner(),
}) async {
  final resolvedArtifactPath = p.normalize(
    p.absolute(projectRoot, ipaOutputPath),
  );
  final managedCommand = StringBuffer(command)
    ..write(
      ' \\\n'
      '  --build-name "\$SMF_PLATFORM_VERSION" \\\n'
      '  --build-number "\$SMF_BUILD_NUMBER" \\\n'
      r'  --export-options-plist "$SMF_EXPORT_OPTIONS_PATH"',
    );
  if (flavor != null) {
    managedCommand.write(' \\\n  --flavor "\$SMF_FLAVOR"');
  }
  await SystemProcessRunner.shell(
    managedCommand.toString(),
    options: RunOptions(
      workingDirectory: projectRoot,
      environment: <String, String>{
        'SMF_PLATFORM': 'ios',
        'SMF_PLATFORM_VERSION': version,
        'SMF_BUILD_NUMBER': buildNumber,
        'SMF_EXPORT_OPTIONS_PATH': exportOptionsPath,
        'SMF_IPA_OUTPUT_PATH': resolvedArtifactPath,
        'SMF_FLAVOR': ?flavor,
      },
    ),
    processRunner: processRunner,
  );
  return findArtifact(projectRoot, ipaOutputPath: ipaOutputPath);
}