getIOSBundleName function

String? getIOSBundleName(
  1. String? bundlePath
)

Implementation

String? getIOSBundleName(String? bundlePath) {
  bundlePath = getAbsolutePath(bundlePath);
  info('Converting $bundlePath to JSON file');
  run('plutil', ['-convert', 'json', '-o', bundlePath + '.json', bundlePath]);
  success('$bundlePath.json file crated');
  var bundleJSONFile = File(bundlePath + '.json');
  var bundleJSON = jsonDecode(bundleJSONFile.readAsStringSync());
  var bundleIdentifier = bundleJSON['CFBundleIdentifier'];
  info('Removing the $bundlePath.json file');
  run('rm', [bundlePath + '.json']);
  success('$bundlePath.json file removed');
  if (isBundleIdentifier(bundleIdentifier)) {
    return bundleIdentifier;
  }
  if (isEnvironmentVariable(bundleIdentifier)) {
    var envVarName = getEnvironmentVariableName(bundleIdentifier)!;
    bundleIdentifier = getXCodeBuildEnvironmentVariable(envVarName);
    return bundleIdentifier;
  }
  return null;
}