Skip to content

Commit

Permalink
[Thierry Yseboodt]: Add support for ODR tags
Browse files Browse the repository at this point in the history
Signed-off-by: Goffredo Marocchi <[email protected]>

# Conflicts:
#	package.json
  • Loading branch information
goff-marocchi committed Jun 12, 2020
1 parent e81ecab commit f818f1a
Show file tree
Hide file tree
Showing 3 changed files with 1,384 additions and 0 deletions.
75 changes: 75 additions & 0 deletions lib/pbxProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {

file.uuid = this.generateUuid();
file.target = opt ? opt.target : undefined;
file.settings = opt ? opt.settings : undefined;

if (!opt.plugin) {
correctForResourcesPath(file, this);
Expand Down Expand Up @@ -2198,4 +2199,78 @@ pbxProject.prototype.removeTargetAttribute = function(prop, target) {
}
}

pbxProject.prototype.addAssetTag = function(assetTagName, resourcesFolder) {
var project = this.getFirstProject()['firstProject'];
if (project['attributes'] === undefined) {
project['attributes'] = {};
}
var attributes = project['attributes']
console.log(this.getFirstProject())
if (attributes['KnownAssetTags'] === undefined) {
attributes['KnownAssetTags'] = [];
}
if (!attributes['KnownAssetTags'].includes(assetTagName)) {
attributes['KnownAssetTags'].push(assetTagName)
}

this.addResourceFile(resourcesFolder, {
"settings": {
"ASSET_TAGS": [
assetTagName
]
}
})
}

pbxProject.prototype.removeTaggedResourceFiles = function() {
for (const [ uuid, value ] of Object.entries(this.pbxBuildFileSection())) {
// console.log(value);
if (value["settings"] !== undefined) {
if (value["settings"]["ASSET_TAGS"] !== undefined && value.fileRef_comment !== undefined) {
const file = this.pbxFileReferenceSection()[value.fileRef]
if (file) {
this.removeResourceFile(file.path)
delete this.pbxBuildFileSection()[uuid]
}
}
}
}
}

pbxProject.prototype.listAssetTags = function() {
var project = this.getFirstProject()['firstProject'];
if (project['attributes'] === undefined) {
return []
}
var attributes = project['attributes']

if (attributes['KnownAssetTags'] == undefined) {
return []
}
return attributes['KnownAssetTags']
}

pbxProject.prototype.removeAssetTags = function() {
var project = this.getFirstProject()['firstProject'];
if (project['attributes'] === undefined) {
project['attributes'] = {};
}
var attributes = project['attributes']
console.log("=======")
// console.log(this.getFirstProject())

if (attributes['KnownAssetTags'] !== undefined) {
console.log(attributes['KnownAssetTags'])
attributes['KnownAssetTags'].forEach(tag => {
console.log(` tag found ${tag}`);

})
}

this.removeTaggedResourceFiles()

attributes['KnownAssetTags'] = [];
}


module.exports = pbxProject;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"node": ">=10.0.0"
},
"dependencies": {
"merge-deep": "^3.0.2",
"simple-plist": "^1.1.0",
"uuid": "^7.0.3"
},
Expand Down
Loading

0 comments on commit f818f1a

Please sign in to comment.