publish method

  1. @override
Future<PublishResult> publish(
  1. File file, {
  2. Map<String, String>? environment,
  3. Map<String, dynamic>? publishArguments,
  4. PublishProgressCallback? onPublishProgress,
})

Implementation

@override
Future<PublishResult> publish(
  File file, {
  Map<String, String>? environment,
  Map<String, dynamic>? publishArguments,
  PublishProgressCallback? onPublishProgress,
}) async {
  // Get type
  String type = file.path.endsWith('.ipa') ? 'ios' : 'osx';
  // Get config
  PublishAppStoreConfig publishConfig =
      PublishAppStoreConfig.parse(environment, publishArguments);
  // Publish to AppStore
  Process process = await Process.start(
    'xcrun',
    [
      'altool',
      '--upload-app',
      '--file',
      file.path,
      '--type',
      type,
      // cmd list
      ...publishConfig.toAppStoreCliDistributeArgs()
    ],
  );
  process.stdout.listen((event) {
    String msg = utf8.decoder.convert(event).trim();
    print(msg);
  });
  process.stderr.listen((event) {
    String msg = utf8.decoder.convert(event).trim();
    print(msg);
  });
  int code = await process.exitCode;
  if (code == 0) {
    return PublishResult(
      url: 'https://appstoreconnect.apple.com/apps',
    );
  } else {
    throw PublishError('$code - Upload of appstore failed');
  }
}