firebaseAppleBundleId function

String firebaseAppleBundleId(
  1. String? value, {
  2. String? targetConfiguration,
})

Resolves the Runner identity before invoking FlutterFire.

Implementation

String firebaseAppleBundleId(String? value, {String? targetConfiguration}) {
  var bundleId = (value ?? "").trim().replaceAll('"', "").replaceAll("'", "");
  if (bundleId == r"$(KATANA_APPLICATION_ID)" ||
      bundleId == r"${KATANA_APPLICATION_ID}") {
    final file = File("ios/Flutter/KatanaTarget.xcconfig");
    final configuration = targetConfiguration ??
        (file.existsSync() ? file.readAsStringSync() : "");
    bundleId =
        RegExp(r"^\s*KATANA_APPLICATION_ID\s*=\s*([^\r\n]+)", multiLine: true)
                .firstMatch(configuration)
                ?.group(1)
                ?.split("//")
                .first
                .trim()
                .replaceAll('"', "")
                .replaceAll("'", "") ??
            "";
    if (bundleId.isEmpty) {
      throw const FormatException(
          "Selected Apple identity is missing. Run katana apply --only nativetarget --target <target> first.");
    }
  }
  if (bundleId.contains(r"$") || bundleId.contains("(")) {
    throw FormatException("Unresolved Apple bundle identifier: $bundleId");
  }
  return bundleId;
}