@@ -325,6 +325,21 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
325325 return { uuid : pbxGroupUuid , pbxGroup : pbxGroup } ;
326326}
327327
328+ pbxProject . prototype . removePbxGroup = function ( groupName ) {
329+ var section = this . hash . project . objects [ 'PBXGroup' ] ,
330+ key , itemKey ;
331+
332+ for ( key in section ) {
333+ // only look for comments
334+ if ( ! COMMENT_KEY . test ( key ) ) continue ;
335+
336+ if ( section [ key ] == groupName ) {
337+ itemKey = key . split ( COMMENT_KEY ) [ 0 ] ;
338+ delete section [ itemKey ] ;
339+ }
340+ }
341+ }
342+
328343pbxProject . prototype . addToPbxFileReferenceSection = function ( file ) {
329344 var commentKey = f ( "%s_comment" , file . fileRef ) ;
330345
@@ -333,22 +348,26 @@ pbxProject.prototype.addToPbxFileReferenceSection = function (file) {
333348}
334349
335350pbxProject . prototype . removeFromPbxFileReferenceSection = function ( file ) {
336-
337- var i ;
338351 var refObj = pbxFileReferenceObj ( file ) ;
339- for ( i in this . pbxFileReferenceSection ( ) ) {
340- if ( this . pbxFileReferenceSection ( ) [ i ] . name == refObj . name ||
341- ( '"' + this . pbxFileReferenceSection ( ) [ i ] . name + '"' ) == refObj . name ||
342- this . pbxFileReferenceSection ( ) [ i ] . path == refObj . path ||
343- ( '"' + this . pbxFileReferenceSection ( ) [ i ] . path + '"' ) == refObj . path ) {
352+ var pbxFileReferenceSection = this . pbxFileReferenceSection ( ) ;
353+ for ( var i in pbxFileReferenceSection ) {
354+ var pbxFileReferenceSectionName = quote ( pbxFileReferenceSection [ i ] . name ) ;
355+ var pbxFileReferenceSectionPath = quote ( pbxFileReferenceSection [ i ] . path ) ;
356+ var refObjName = quote ( refObj . name ) ;
357+ var refObjPath = quote ( refObj . path ) ;
358+ if ( pbxFileReferenceSectionName == refObjName ||
359+ pbxFileReferenceSectionName == refObjPath ||
360+ pbxFileReferenceSectionPath == refObjPath ||
361+ pbxFileReferenceSectionPath == refObjName ) {
344362 file . fileRef = file . uuid = i ;
345- delete this . pbxFileReferenceSection ( ) [ i ] ;
363+ delete pbxFileReferenceSection [ i ] ;
346364 break ;
347365 }
348366 }
349- var commentKey = f ( "%s_comment" , file . fileRef ) ;
350- if ( this . pbxFileReferenceSection ( ) [ commentKey ] != undefined ) {
351- delete this . pbxFileReferenceSection ( ) [ commentKey ] ;
367+
368+ if ( typeof file . fileRef !== 'undefined' ) {
369+ var commentKey = f ( "%s_comment" , file . fileRef ) ;
370+ delete pbxFileReferenceSection [ commentKey ] ;
352371 }
353372
354373 return file ;
@@ -376,11 +395,13 @@ pbxProject.prototype.addToResourcesPbxGroup = function (file) {
376395}
377396
378397pbxProject . prototype . removeFromResourcesPbxGroup = function ( file ) {
379- var pluginsGroupChildren = this . pbxGroupByName ( 'Resources' ) . children , i ;
380- for ( i in pluginsGroupChildren ) {
381- if ( pbxGroupChild ( file ) . value == pluginsGroupChildren [ i ] . value &&
382- pbxGroupChild ( file ) . comment == pluginsGroupChildren [ i ] . comment ) {
383- pluginsGroupChildren . splice ( i , 1 ) ;
398+ var groupChild = pbxGroupChild ( file ) ;
399+ var resourcesGroupChildren = this . pbxGroupByName ( 'Resources' ) . children ;
400+ for ( var i in resourcesGroupChildren ) {
401+ var resourcesGroupChild = resourcesGroupChildren [ i ] ;
402+ if ( ( typeof groupChild . value === 'undefined' || groupChild . value == resourcesGroupChild . value ) &&
403+ groupChild . comment == resourcesGroupChild . comment ) {
404+ resourcesGroupChildren . splice ( i , 1 ) ;
384405 break ;
385406 }
386407 }
@@ -1086,4 +1107,8 @@ function unquote(str) {
10861107 if ( str ) return str . replace ( / ^ " ( .* ) " $ / , "$1" ) ;
10871108}
10881109
1110+ function quote ( str ) {
1111+ if ( str ) return '"' + unquote ( str ) + '"' ;
1112+ }
1113+
10891114module . exports = pbxProject ;
0 commit comments