Skip to content

Commit 6577ce4

Browse files
committed
[Thierry Yseboodt]: Add support for ODR tags
Signed-off-by: Goffredo Marocchi <goffredo.marocchi@gamesys.co.uk>
1 parent 68d3a37 commit 6577ce4

File tree

3 files changed

+1384
-0
lines changed

3 files changed

+1384
-0
lines changed

lib/pbxProject.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {
253253

254254
file.uuid = this.generateUuid();
255255
file.target = opt ? opt.target : undefined;
256+
file.settings = opt ? opt.settings : undefined;
256257

257258
if (!opt.plugin) {
258259
correctForResourcesPath(file, this);
@@ -2141,4 +2142,78 @@ pbxProject.prototype.removeTargetAttribute = function(prop, target) {
21412142
}
21422143
}
21432144

2145+
pbxProject.prototype.addAssetTag = function(assetTagName, resourcesFolder) {
2146+
var project = this.getFirstProject()['firstProject'];
2147+
if (project['attributes'] === undefined) {
2148+
project['attributes'] = {};
2149+
}
2150+
var attributes = project['attributes']
2151+
console.log(this.getFirstProject())
2152+
if (attributes['KnownAssetTags'] === undefined) {
2153+
attributes['KnownAssetTags'] = [];
2154+
}
2155+
if (!attributes['KnownAssetTags'].includes(assetTagName)) {
2156+
attributes['KnownAssetTags'].push(assetTagName)
2157+
}
2158+
2159+
this.addResourceFile(resourcesFolder, {
2160+
"settings": {
2161+
"ASSET_TAGS": [
2162+
assetTagName
2163+
]
2164+
}
2165+
})
2166+
}
2167+
2168+
pbxProject.prototype.removeTaggedResourceFiles = function() {
2169+
for (const [ uuid, value ] of Object.entries(this.pbxBuildFileSection())) {
2170+
// console.log(value);
2171+
if (value["settings"] !== undefined) {
2172+
if (value["settings"]["ASSET_TAGS"] !== undefined && value.fileRef_comment !== undefined) {
2173+
const file = this.pbxFileReferenceSection()[value.fileRef]
2174+
if (file) {
2175+
this.removeResourceFile(file.path)
2176+
delete this.pbxBuildFileSection()[uuid]
2177+
}
2178+
}
2179+
}
2180+
}
2181+
}
2182+
2183+
pbxProject.prototype.listAssetTags = function() {
2184+
var project = this.getFirstProject()['firstProject'];
2185+
if (project['attributes'] === undefined) {
2186+
return []
2187+
}
2188+
var attributes = project['attributes']
2189+
2190+
if (attributes['KnownAssetTags'] == undefined) {
2191+
return []
2192+
}
2193+
return attributes['KnownAssetTags']
2194+
}
2195+
2196+
pbxProject.prototype.removeAssetTags = function() {
2197+
var project = this.getFirstProject()['firstProject'];
2198+
if (project['attributes'] === undefined) {
2199+
project['attributes'] = {};
2200+
}
2201+
var attributes = project['attributes']
2202+
console.log("=======")
2203+
// console.log(this.getFirstProject())
2204+
2205+
if (attributes['KnownAssetTags'] !== undefined) {
2206+
console.log(attributes['KnownAssetTags'])
2207+
attributes['KnownAssetTags'].forEach(tag => {
2208+
console.log(` tag found ${tag}`);
2209+
2210+
})
2211+
}
2212+
2213+
this.removeTaggedResourceFiles()
2214+
2215+
attributes['KnownAssetTags'] = [];
2216+
}
2217+
2218+
21442219
module.exports = pbxProject;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"node": ">=6.0.0"
1212
},
1313
"dependencies": {
14+
"merge-deep": "^3.0.2",
1415
"simple-plist": "^1.0.0",
1516
"uuid": "^3.3.2"
1617
},

0 commit comments

Comments
 (0)