hooks/AfterPluginInstall.js
function(xcConfigBuildFilePath) {
        let lines = fs.readFileSync(xcConfigBuildFilePath, 'utf8').split('\n');
        let paths = hookData.headerPaths;

        let headerSearchPathLineNumber;

        lines.forEach((l, i) => {
            if (l.indexOf('HEADER_SEARCH_PATHS') > -1) {
                headerSearchPathLineNumber = i;
            }
        });

        if (headerSearchPathLineNumber) {
            for(let actualPath of paths) {
                if (lines[headerSearchPathLineNumber].indexOf(actualPath) == -1) {
                    lines[headerSearchPathLineNumber] += ` ${actualPath}`;
                    console.log(`${actualPath} was added to the search paths`);
                }
                else {
                    console.log(`${actualPath} was already setup in build.xcconfig`);
                }
            }
        }
        else {
            lines[lines.length - 1] = 'HEADER_SEARCH_PATHS = ';
            for(let actualPath of paths) {
                lines[lines.length - 1] += actualPath;
            }
        }

        let newConfig = lines.join('\n');

        fs.writeFile(xcConfigBuildFilePath, newConfig, function (err) {
            if (err) {
                console.log(`Error updating build.xcconfig: ${err}`);
                return;
            }
            console.log('Successfully updated HEADER_SEARCH_PATHS in build.xcconfig');
        });

    }
function(xcConfigBuildFilePath) {
        let lines = fs.readFileSync(xcConfigBuildFilePath, 'utf8').split('\n');
        let paths = hookData.headerPaths;

        let headerSearchPathLineNumber;

        lines.forEach((l, i) => {
            if (l.indexOf('HEADER_SEARCH_PATHS') > -1) {
                headerSearchPathLineNumber = i;
            }
        });

        if (headerSearchPathLineNumber) {
            for(let actualPath of paths) {
                if (lines[headerSearchPathLineNumber].indexOf(actualPath) == -1) {
                    lines[headerSearchPathLineNumber] += ` ${actualPath}`;
                    console.log(`${actualPath} was added to the search paths`);
                }
                else {
                    console.log(`${actualPath} was already setup in build.xcconfig`);
                }
            }
        }
        else {
            lines[lines.length - 1] = 'HEADER_SEARCH_PATHS = ';
            for(let actualPath of paths) {
                lines[lines.length - 1] += actualPath;
            }
        }

        let newConfig = lines.join('\n');

        fs.writeFile(xcConfigBuildFilePath, newConfig, function (err) {
            if (err) {
                console.log(`Error updating build.xcconfig: ${err}`);
                return;
            }
            console.log('Successfully updated HEADER_SEARCH_PATHS in build.xcconfig');
        });

    }
function ( xcConfigBuildFilePath ) { let lines = fs . readFileSync ( xcConfigBuildFilePath , 'utf8' ) . split ( '\n' ) ; let paths = hookData . headerPaths ; let headerSearchPathLineNumber ; lines . forEach ( ( l , i ) => { if ( l . indexOf ( 'HEADER_SEARCH_PATHS' ) > - 1 ) { headerSearchPathLineNumber = i ; } } ) ; if ( headerSearchPathLineNumber ) { for ( let actualPath of paths ) { if ( lines [ headerSearchPathLineNumber ] . indexOf ( actualPath ) == - 1 ) { lines [ headerSearchPathLineNumber ] += ` ${ actualPath } ` ; console . log ( ` ${ actualPath } ` ) ; } else { console . log ( ` ${ actualPath } ` ) ; } } } else { lines [ lines . length - 1 ] = 'HEADER_SEARCH_PATHS = ' ; for ( let actualPath of paths ) { lines [ lines . length - 1 ] += actualPath ; } } let newConfig = lines . join ( '\n' ) ; fs . writeFile ( xcConfigBuildFilePath , newConfig , function ( err ) { if ( err ) { console . log ( ` ${ err } ` ) ; return ; } console . log ( 'Successfully updated HEADER_SEARCH_PATHS in build.xcconfig' ) ; } ) ; }
Read the build config, add the correct Header Search Paths to the config before calling modifyAppDelegate.
Read the build config add the correct Header Search Paths to the config before calling modifyAppDelegate .