changeIosBundleId method

Future<File?> changeIosBundleId({
  1. String? bundleId,
})

Implementation

Future<File?> changeIosBundleId({String? bundleId}) async {
  List? contentLineByLine = await readFileAsLineByline(
    filePath: iosProjectPbxprojPath,
  );
  if (checkFileExists(contentLineByLine)) {
    logger.w('''
    Ios BundleId could not be changed because,
    The related file could not be found in that path:  $iosProjectPbxprojPath
    ''');
    return null;
  }
  for (var i = 0; i < contentLineByLine!.length; i++) {
    if (contentLineByLine[i].contains('PRODUCT_BUNDLE_IDENTIFIER')) {
      contentLineByLine[i] = '				PRODUCT_BUNDLE_IDENTIFIER = $bundleId;';
    }
  }
  var writtenFile = await writeFile(
    filePath: iosProjectPbxprojPath,
    content: contentLineByLine.join('\n'),
  );
  logger.i('IOS BundleIdentifier changed successfully to : $bundleId');
  return writtenFile;
}