function cleanIcons()

in lib/prepare.js [554:585]


function cleanIcons (projectRoot, projectConfig, locations) {
    const icons = projectConfig.getIcons('ios');
    if (icons.length === 0) {
        return Promise.resolve();
    }

    const platformProjDir = path.relative(projectRoot, locations.xcodeCordovaProj);
    const iconsDir = path.join(platformProjDir, 'Assets.xcassets', 'AppIcon.appiconset');

    return checkOrAssumeXcodeVersion()
        .then((xcodeversion) => {
            const resourceMap = mapIconResources(icons, iconsDir, xcodeversion);
            Object.keys(resourceMap).forEach(targetIconPath => {
                resourceMap[targetIconPath] = null;
            });
            events.emit('verbose', `Cleaning icons at ${iconsDir}`);

            // Source paths are removed from the map, so updatePaths() will delete the target files.
            FileUpdater.updatePaths(
                resourceMap, { rootDir: projectRoot, all: true }, logFileOp);

            const contentsJSON = generateAppIconContentsJson(resourceMap);

            // delete filename from contents.json
            contentsJSON.images.forEach(image => {
                image.filename = undefined;
            });

            events.emit('verbose', 'Updating App Icon image set contents.json');
            fs.writeFileSync(path.join(projectRoot, iconsDir, 'Contents.json'), JSON.stringify(contentsJSON, null, 2));
        });
}