samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js
function updateIosPbxProj(xcodeProjectPath, configItems) {
        var xcodeProject = xcode.project(xcodeProjectPath);
        xcodeProject.parse(function(err){
            if(err){
                // shell is undefined if android platform has been removed and added with a new package id but ios stayed the same.
                var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(err);
                if(typeof shell !== "undefined" && shell !== null){
                    shell.echo(msg);
                } else{
                    logger.error(msg + ' - Maybe you forgot to remove/add the ios platform?');
                }
            }else{
                _.each(configItems, function (item) {
                    switch(item.type){
                        case "XCBuildConfiguration":
                            var buildConfig = xcodeProject.pbxXCBuildConfigurationSection();
                            var replaced = updateXCBuildConfiguration(item, buildConfig, "replace");
                            if(!replaced){
                                updateXCBuildConfiguration(item, buildConfig, "add");
                            }
                            break;
                    }
                });
                fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
            }
        });
    }
function updateIosPbxProj(xcodeProjectPath, configItems) {
        var xcodeProject = xcode.project(xcodeProjectPath);
        xcodeProject.parse(function(err){
            if(err){
                // shell is undefined if android platform has been removed and added with a new package id but ios stayed the same.
                var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(err);
                if(typeof shell !== "undefined" && shell !== null){
                    shell.echo(msg);
                } else{
                    logger.error(msg + ' - Maybe you forgot to remove/add the ios platform?');
                }
            }else{
                _.each(configItems, function (item) {
                    switch(item.type){
                        case "XCBuildConfiguration":
                            var buildConfig = xcodeProject.pbxXCBuildConfigurationSection();
                            var replaced = updateXCBuildConfiguration(item, buildConfig, "replace");
                            if(!replaced){
                                updateXCBuildConfiguration(item, buildConfig, "add");
                            }
                            break;
                    }
                });
                fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
            }
        });
    }
function updateIosPbxProj ( xcodeProjectPath , configItems ) { var xcodeProject = xcode . project ( xcodeProjectPath ) ; xcodeProject . parse ( function ( err ) { if ( err ) { // shell is undefined if android platform has been removed and added with a new package id but ios stayed the same. var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON . stringify ( err ) ; if ( typeof shell !== "undefined" && shell !== null ) { shell . echo ( msg ) ; } else { logger . error ( msg + ' - Maybe you forgot to remove/add the ios platform?' ) ; } } else { _ . each ( configItems , function ( item ) { switch ( item . type ) { case "XCBuildConfiguration" : var buildConfig = xcodeProject . pbxXCBuildConfigurationSection ( ) ; var replaced = updateXCBuildConfiguration ( item , buildConfig , "replace" ) ; if ( ! replaced ) { updateXCBuildConfiguration ( item , buildConfig , "add" ) ; } break ; } } ) ; fs . writeFileSync ( xcodeProjectPath , xcodeProject . writeSync ( ) , 'utf-8' ) ; } } ) ; }
Updates the project.pbxproj file with data from config.xml
@param {String} xcodeProjectPath - path to XCode project file
@param {Array} configItems - config items to update project file with
Updates the project . pbxproj file with data from config . xml