@JohnWalthour
I needed to do this for the cordova plugin that I create, and with "after installing the plug-in" is possible. I realized that after installing and modifying HEADER_SEARCH_PATHS in ${project}/platforms/ios/cordova/build.xcconfig I can run the node.js script.
It takes to get dirty, but it works great. One of the most important components of this work is that the Bundle name is assigned ${PRODUCT_NAME} in info.plist, so you can use ${PRODUCT_NAME} in your build.xcconfig and it will interpolate with your project / application name. Cordoba already has a set of ${PRODUCT_NAME} variables for you.
Here is the relevant code -
plugin.xml (abbreviated for brevity and important material)
<platform name="ios"> ..... <hook type="after_plugin_install" src="hooks/AfterPluginInstall.js" /> <hook type="before_plugin_uninstall" src="hooks/BeforePluginUninstall.js" /> ..... </platform>
AfterPluginInstall.js
#!/usr/bin/env node 'use strict'; let cwd = process.cwd(); let fs = require('fs'); let path = require('path'); console.log('InstagramAssetsPicker AfterPluginInstall.js, attempting to modify build.xcconfig'); let xcConfigBuildFilePath = path.join(cwd, 'platforms', 'ios', 'cordova', 'build.xcconfig'); console.log('xcConfigBuildFilePath: ', xcConfigBuildFilePath); let lines = fs.readFileSync(xcConfigBuildFilePath, 'utf8').split('\n'); let headerSearchPathLineNumber; lines.forEach((l, i) => { if (l.indexOf('HEADER_SEARCH_PATHS') > -1) { headerSearchPathLineNumber = i; } }); if (lines[headerSearchPathLineNumber].indexOf('InstagramAssetsPicker') > -1) { console.log('build.xcconfig already setup for InstagramAssetsPicker'); return; } lines[headerSearchPathLineNumber] += ' "$(SRCROOT)/$(PRODUCT_NAME)/cordova-plugin-InstagramAssetsPicker/GPUImageHeaders"'; let newConfig = lines.join('\n'); fs.writeFile(xcConfigBuildFilePath, newConfig, function (err) { if (err) { console.log('error updating build.xcconfig, err: ', err); return; } console.log('successfully updated HEADER_SEARCH_PATHS in build.xcconfig'); });
BeforePluginUninstall.js
#!/usr/bin/env node 'use strict'; let cwd = process.cwd(); let fs = require('fs'); let path = require('path'); console.log('InstagramAssetsPicker BeforePluginInstall.js, attempting to modify build.xcconfig'); let xcConfigBuildFilePath = path.join(cwd, 'platforms', 'ios', 'cordova', 'build.xcconfig'); console.log('xcConfigBuildFilePath: ', xcConfigBuildFilePath); let lines = fs.readFileSync(xcConfigBuildFilePath, 'utf8').split('\n'); let headerSearchPathLineNumber; lines.forEach((l, i) => { if (l.indexOf('HEADER_SEARCH_PATHS') > -1) { headerSearchPathLineNumber = i; } }); if (lines[headerSearchPathLineNumber].indexOf('InstagramAssetsPicker') === -1) { console.log('build.xcconfig does not have header path for InstagramAssetsPicker.'); return; } let line = lines[headerSearchPathLineNumber]; lines[headerSearchPathLineNumber] = line.replace(/\ "\$\(SRCROOT\)\/\$\(PRODUCT_NAME\)\/cordova-plugin-InstagramAssetsPicker\/GPUImageHeaders\"/i, ''); let newConfig = lines.join('\n'); fs.writeFile(xcConfigBuildFilePath, newConfig, function (err) { if (err) { console.log('error updating build.xcconfig, err: ', err); return; } console.log('successfully updated HEADER_SEARCH_PATHS in build.xcconfig'); });