Skip to content

Commit d607e87

Browse files
author
Kristian D. Dimitrov
committed
fix: add and remove pbxGroup
1 parent e2a7eee commit d607e87

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/pbxProject.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,16 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
523523
isa: 'PBXGroup',
524524
children: [],
525525
name: name,
526-
path: path,
527526
sourceTree: sourceTree ? sourceTree : '"<group>"'
528-
},//path is mandatory only for the main group
527+
},
529528
fileReferenceSection = this.pbxFileReferenceSection(),
530529
filePathToReference = {};
531530

531+
//path is mandatory only for the main group
532+
if(!opt.filesRelativeToProject) {
533+
pbxGroup.path = path;
534+
}
535+
532536
for (var key in fileReferenceSection) {
533537
// only look for comments
534538
if (!COMMENT_KEY.test(key)) continue;
@@ -602,7 +606,7 @@ pbxProject.prototype.removePbxGroup = function(groupName, path) {
602606
return;
603607
}
604608

605-
path = path || $path.dirname(this.filepath);
609+
path = path || "";
606610

607611
var children = group.children;
608612

@@ -620,7 +624,7 @@ pbxProject.prototype.removePbxGroup = function(groupName, path) {
620624
if(mainGroup) {
621625
var mainGroupChildren = this.findMainPbxGroup().children, i;
622626
for(i in mainGroupChildren) {
623-
if (mainGroupChildren[i].comment == name) {
627+
if (mainGroupChildren[i].comment == groupName) {
624628
mainGroupChildren.splice(i, 1);
625629
}
626630
}

test/parser/projects/expected/with_omit_empty_values_disabled_expected.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@
260260
children = (
261261
);
262262
name = CustomGroup;
263-
path = undefined;
264263
sourceTree = "<group>";
264+
path = undefined;
265265
};
266266
/* End PBXGroup section */
267267

0 commit comments

Comments
 (0)