Skip to content

Commit 9baa6ff

Browse files
committed
Added addToOtherLinkerFlags and removeFromOtherLinkerFlags to pbxProject
1 parent 8155233 commit 9baa6ff

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

lib/pbxProject.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,52 @@ pbxProject.prototype.addToHeaderSearchPaths = function (file) {
850850
}
851851
}
852852
}
853+
854+
pbxProject.prototype.addToOtherLinkerFlags = function (flag) {
855+
var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
856+
INHERITED = '"$(inherited)"',
857+
OTHER_LDFLAGS = 'OTHER_LDFLAGS',
858+
config, buildSettings;
859+
860+
for (config in configurations) {
861+
buildSettings = configurations[config].buildSettings;
862+
863+
if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
864+
continue;
865+
866+
if (!buildSettings[OTHER_LDFLAGS]
867+
|| buildSettings[OTHER_LDFLAGS] === INHERITED) {
868+
buildSettings[OTHER_LDFLAGS] = [INHERITED];
869+
}
870+
871+
buildSettings[OTHER_LDFLAGS].push(flag);
872+
}
873+
}
874+
875+
pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) {
876+
var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
877+
OTHER_LDFLAGS = 'OTHER_LDFLAGS',
878+
config, buildSettings;
879+
880+
for (config in configurations) {
881+
buildSettings = configurations[config].buildSettings;
882+
883+
if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) {
884+
continue;
885+
}
886+
887+
if (buildSettings[OTHER_LDFLAGS]) {
888+
var matches = buildSettings[OTHER_LDFLAGS].filter(function (p) {
889+
return p.indexOf(flag) > -1;
890+
});
891+
matches.forEach(function (m) {
892+
var idx = buildSettings[OTHER_LDFLAGS].indexOf(m);
893+
buildSettings[OTHER_LDFLAGS].splice(idx, 1);
894+
});
895+
}
896+
}
897+
}
898+
853899
// a JS getter. hmmm
854900
pbxProject.prototype.__defineGetter__("productName", function () {
855901
var configurations = nonComments(this.pbxXCBuildConfigurationSection()),

0 commit comments

Comments
 (0)