hooks/iosBeforePrepareHook.js
function run(ctx) {
  var projectRoot = ctx.opts.projectRoot;
  var iosProjectFilePath = path.join(projectRoot, 'platforms', 'ios');
  var configXmlHelper = new ConfigXmlHelper(ctx);
  var newProjectName = configXmlHelper.getProjectName();

  var oldProjectName = getOldProjectName(iosProjectFilePath);

  // if name has not changed - do nothing
  if (oldProjectName.length && oldProjectName === newProjectName) {
    return;
  }

  console.log('Project name has changed. Renaming .entitlements file.');

  // if it does - rename it
  var oldEntitlementsFilePath = path.join(iosProjectFilePath, oldProjectName, 'Resources', oldProjectName + '.entitlements');
  var newEntitlementsFilePath = path.join(iosProjectFilePath, oldProjectName, 'Resources', newProjectName + '.entitlements');

  try {
    fs.renameSync(oldEntitlementsFilePath, newEntitlementsFilePath);
  } catch (err) {
    console.warn('Failed to rename .entitlements file.');
    console.warn(err);
  }
}
function run(ctx) {
  var projectRoot = ctx.opts.projectRoot;
  var iosProjectFilePath = path.join(projectRoot, 'platforms', 'ios');
  var configXmlHelper = new ConfigXmlHelper(ctx);
  var newProjectName = configXmlHelper.getProjectName();

  var oldProjectName = getOldProjectName(iosProjectFilePath);

  // if name has not changed - do nothing
  if (oldProjectName.length && oldProjectName === newProjectName) {
    return;
  }

  console.log('Project name has changed. Renaming .entitlements file.');

  // if it does - rename it
  var oldEntitlementsFilePath = path.join(iosProjectFilePath, oldProjectName, 'Resources', oldProjectName + '.entitlements');
  var newEntitlementsFilePath = path.join(iosProjectFilePath, oldProjectName, 'Resources', newProjectName + '.entitlements');

  try {
    fs.renameSync(oldEntitlementsFilePath, newEntitlementsFilePath);
  } catch (err) {
    console.warn('Failed to rename .entitlements file.');
    console.warn(err);
  }
}
function run ( ctx ) { var projectRoot = ctx . opts . projectRoot ; var iosProjectFilePath = path . join ( projectRoot , 'platforms' , 'ios' ) ; var configXmlHelper = new ConfigXmlHelper ( ctx ) ; var newProjectName = configXmlHelper . getProjectName ( ) ; var oldProjectName = getOldProjectName ( iosProjectFilePath ) ; // if name has not changed - do nothing if ( oldProjectName . length && oldProjectName === newProjectName ) { return ; } console . log ( 'Project name has changed. Renaming .entitlements file.' ) ; // if it does - rename it var oldEntitlementsFilePath = path . join ( iosProjectFilePath , oldProjectName , 'Resources' , oldProjectName + '.entitlements' ) ; var newEntitlementsFilePath = path . join ( iosProjectFilePath , oldProjectName , 'Resources' , newProjectName + '.entitlements' ) ; try { fs . renameSync ( oldEntitlementsFilePath , newEntitlementsFilePath ) ; } catch ( err ) { console . warn ( 'Failed to rename .entitlements file.' ) ; console . warn ( err ) ; } }
Run the hook logic.

@param {Object} ctx - cordova context object
Run the hook logic .