@@ -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 ) ;
@@ -2198,4 +2199,78 @@ pbxProject.prototype.removeTargetAttribute = function(prop, target) {
21982199 }
21992200}
22002201
2202+ pbxProject . prototype . addAssetTag = function ( assetTagName , resourcesFolder ) {
2203+ var project = this . getFirstProject ( ) [ 'firstProject' ] ;
2204+ if ( project [ 'attributes' ] === undefined ) {
2205+ project [ 'attributes' ] = { } ;
2206+ }
2207+ var attributes = project [ 'attributes' ]
2208+ console . log ( this . getFirstProject ( ) )
2209+ if ( attributes [ 'KnownAssetTags' ] === undefined ) {
2210+ attributes [ 'KnownAssetTags' ] = [ ] ;
2211+ }
2212+ if ( ! attributes [ 'KnownAssetTags' ] . includes ( assetTagName ) ) {
2213+ attributes [ 'KnownAssetTags' ] . push ( assetTagName )
2214+ }
2215+
2216+ this . addResourceFile ( resourcesFolder , {
2217+ "settings" : {
2218+ "ASSET_TAGS" : [
2219+ assetTagName
2220+ ]
2221+ }
2222+ } )
2223+ }
2224+
2225+ pbxProject . prototype . removeTaggedResourceFiles = function ( ) {
2226+ for ( const [ uuid , value ] of Object . entries ( this . pbxBuildFileSection ( ) ) ) {
2227+ // console.log(value);
2228+ if ( value [ "settings" ] !== undefined ) {
2229+ if ( value [ "settings" ] [ "ASSET_TAGS" ] !== undefined && value . fileRef_comment !== undefined ) {
2230+ const file = this . pbxFileReferenceSection ( ) [ value . fileRef ]
2231+ if ( file ) {
2232+ this . removeResourceFile ( file . path )
2233+ delete this . pbxBuildFileSection ( ) [ uuid ]
2234+ }
2235+ }
2236+ }
2237+ }
2238+ }
2239+
2240+ pbxProject . prototype . listAssetTags = function ( ) {
2241+ var project = this . getFirstProject ( ) [ 'firstProject' ] ;
2242+ if ( project [ 'attributes' ] === undefined ) {
2243+ return [ ]
2244+ }
2245+ var attributes = project [ 'attributes' ]
2246+
2247+ if ( attributes [ 'KnownAssetTags' ] == undefined ) {
2248+ return [ ]
2249+ }
2250+ return attributes [ 'KnownAssetTags' ]
2251+ }
2252+
2253+ pbxProject . prototype . removeAssetTags = function ( ) {
2254+ var project = this . getFirstProject ( ) [ 'firstProject' ] ;
2255+ if ( project [ 'attributes' ] === undefined ) {
2256+ project [ 'attributes' ] = { } ;
2257+ }
2258+ var attributes = project [ 'attributes' ]
2259+ console . log ( "=======" )
2260+ // console.log(this.getFirstProject())
2261+
2262+ if ( attributes [ 'KnownAssetTags' ] !== undefined ) {
2263+ console . log ( attributes [ 'KnownAssetTags' ] )
2264+ attributes [ 'KnownAssetTags' ] . forEach ( tag => {
2265+ console . log ( ` tag found ${ tag } ` ) ;
2266+
2267+ } )
2268+ }
2269+
2270+ this . removeTaggedResourceFiles ( )
2271+
2272+ attributes [ 'KnownAssetTags' ] = [ ] ;
2273+ }
2274+
2275+
22012276module . exports = pbxProject ;
0 commit comments