Skip to content
Permalink
Browse files
Update build property by targetname (#106)
* feature: update build property by target name
* fix update build property by target name
* Add tests for 'updateBuildProperty' with multiple targets

Co-authored-by: Erisu <ellis.bryan@gmail.com>
  • Loading branch information
NiklasMerz and erisu committed Apr 9, 2020
1 parent 022c69e commit 511a06fbc965ea4ee1a2d91b22b0d35ed7f754d4
Showing 3 changed files with 775 additions and 1 deletion.
@@ -1124,11 +1124,36 @@ pbxProject.prototype.removeBuildProperty = function(prop, build_name) {
* @param prop {String}
* @param value {String|Array|Object|Number|Boolean}
* @param build {String} Release or Debug
* @param targetName {String} the target which will be updated
*/
pbxProject.prototype.updateBuildProperty = function(prop, value, build) {
pbxProject.prototype.updateBuildProperty = function(prop, value, build, targetName) {
let validConfigs = [];

if(targetName) {
const target = this.pbxTargetByName(targetName);
const targetBuildConfigs = target && target.buildConfigurationList;

const xcConfigList = this.pbxXCConfigurationList();

// Collect the UUID's from the configuration of our target
for (const configName in xcConfigList) {
if (!COMMENT_KEY.test(configName) && targetBuildConfigs === configName) {
const buildVariants = xcConfigList[configName].buildConfigurations;

for (const item of buildVariants) {
validConfigs.push(item.value);
}

break;
}
}
}

var configs = this.pbxXCBuildConfigurationSection();
for (var configName in configs) {
if (!COMMENT_KEY.test(configName)) {
if (targetName && !validConfigs.includes(configName)) continue;

var config = configs[configName];
if ( (build && config.name === build) || (!build) ) {
config.buildSettings[prop] = value;

0 comments on commit 511a06f

Please sign in to comment.