@@ -669,27 +669,35 @@ pbxProject.prototype.removePbxGroup = function(groupName, path) {
669
669
if ( ! groupKey ) {
670
670
return ;
671
671
}
672
+
673
+ this . removePbxGroupByKey ( groupKey , path ) ;
674
+ }
675
+
676
+ pbxProject . prototype . removePbxGroupByKey = function ( groupKey , path ) {
672
677
var group = this . getPBXGroupByKey ( groupKey ) || this . getPBXVariantGroupByKey ( groupKey )
678
+
679
+ if ( ! group ) {
680
+ return ;
681
+ }
673
682
674
683
path = path || "" ;
675
-
676
684
var children = group . children ;
677
685
678
686
for ( i in children ) {
679
687
var file = new pbxFile ( $path . join ( path , children [ i ] . comment ) ) ;
680
688
file . fileRef = children [ i ] . value ;
681
689
file . uuid = file . fileRef ;
682
- this . removePbxGroup ( children [ i ] . comment , $path . join ( path , children [ i ] . comment ) ) ;
683
- this . removeFromPbxFileReferenceSection ( file ) ;
690
+ this . removePbxGroupByKey ( children [ i ] . value , $path . join ( path , children [ i ] . comment ) ) ;
691
+ this . removeFromPbxFileReferenceSectionByUuid ( children [ i ] . value ) ;
684
692
this . removeFromPbxBuildFileSection ( file ) ;
685
693
this . removeFromPbxSourcesBuildPhase ( file ) ;
686
694
}
687
695
688
696
var mainGroup = this . findMainPbxGroup ( ) ;
689
697
if ( mainGroup ) {
690
- var mainGroupChildren = this . findMainPbxGroup ( ) . children , i ;
698
+ var mainGroupChildren = mainGroup . children , i ;
691
699
for ( i in mainGroupChildren ) {
692
- if ( mainGroupChildren [ i ] . comment == groupName ) {
700
+ if ( mainGroupChildren [ i ] . value == groupKey ) {
693
701
mainGroupChildren . splice ( i , 1 ) ;
694
702
}
695
703
}
@@ -702,15 +710,7 @@ pbxProject.prototype.removePbxGroup = function(groupName, path) {
702
710
section = this . hash . project . objects [ 'PBXGroup' ] ;
703
711
}
704
712
705
- for ( key in section ) {
706
- // only look for comments
707
- if ( ! COMMENT_KEY . test ( key ) ) continue ;
708
-
709
- if ( section [ key ] == groupName ) {
710
- itemKey = key . split ( COMMENT_KEY ) [ 0 ] ;
711
- delete section [ itemKey ] ;
712
- }
713
- }
713
+ removeItemAndCommentFromSectionByUuid ( section , groupKey ) ;
714
714
}
715
715
716
716
pbxProject . prototype . addToPbxProjectSection = function ( target ) {
@@ -759,6 +759,12 @@ pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) {
759
759
return file ;
760
760
}
761
761
762
+ pbxProject . prototype . removeFromPbxFileReferenceSectionByUuid = function ( fileUuid ) {
763
+ var section = this . pbxFileReferenceSection ( ) ;
764
+
765
+ removeItemAndCommentFromSectionByUuid ( section , fileUuid ) ;
766
+ }
767
+
762
768
pbxProject . prototype . addToXcVersionGroupSection = function ( file ) {
763
769
if ( ! file . models || ! file . currentModel ) {
764
770
throw new Error ( "Cannot create a XCVersionGroup section from not a data model document file" ) ;
0 commit comments