isValid static method

(bool, String?) isValid(
  1. YamlMap data,
  2. TargetPlatform tp
)

Checks if the given config in the pubspec is valid or not

Should be called before the fromMap function

Implementation

static (bool, String?) isValid(yaml.YamlMap data, TargetPlatform tp) {
  if (!data.containsKey("keyID") || data["keyID"] == "" || !Platform.environment.containsKey(data["keyID"]) || Platform.environment["keyID"] == "") {
    return (
      false,
      "'keyID' env variable is missing from the publish config for ${tp.name} or invalid. You can get the key ID by creating an API key from 'App Store Connect' > 'Users & Access' > 'Integrations'.",
    );
  }

  if (!data.containsKey("issuerID") || data["issuerID"] == "" || !Platform.environment.containsKey(data["issuerID"]) || Platform.environment["issuerID"] == "") {
    return (
      false,
      "'issuerID' env variable is missing from the publish config for ${tp.name} or invalid. You can get the issuer ID by visiting 'App Store Connect' > 'Users & Access' > 'Integrations'.",
    );
  }

  if (!data.containsKey("appAppleID") || data["appAppleID"] == "" || !Platform.environment.containsKey(data["appAppleID"]) || Platform.environment["appAppleID"] == "") {
    return (
      false,
      "'appAppleID' env variable is missing from the publish config for ${tp.name} or invalid. You can get the apple ID of your app from the 'App Information' section of your app in App Store Connect.",
    );
  }

  if (!data.containsKey("bundleID") || data["bundleID"] == "") {
    return (false, "'bundleID' is missing from the publish config for ${tp.name}. The bundle id is structured as 'com.example.your_app'.");
  }

  if (!data.containsKey("outputFilePath") || data["outputFilePath"] == "") {
    String examplePath = "build/ios/ipa/yourapp.ipa";
    if (tp == TargetPlatform.macos) {
      examplePath = "build/macos/Build/Products/Release/yourapp.app";
    }
    return (
      false,
      "'outputFilePath' is missing from the publish config for ${tp.name}. This is the path to the build ${tp == TargetPlatform.macos ? "folder" : "file"} generated by the 'flutter build' command. e.g. $examplePath",
    );
  }

  return (true, null);
}