@@ -37,17 +37,24 @@ + (XCGroup *)groupWithProject:(XCProject *)project key:(NSString *)key alias:(NS
37
37
children : (NSArray *)children
38
38
{
39
39
40
- return [[XCGroup alloc ] initWithProject: project key: key alias: alias path: path children: children];
40
+ return [[XCGroup alloc ] initWithProject: project key: key alias: alias path: path children: children memberType: PBXGroupType];
41
+ }
42
+
43
+ + (XCGroup *)groupWithProject : (XCProject *)project key : (NSString *)key alias : (NSString *)alias path : (NSString *)path children : (NSArray <id<XcodeGroupMember>> *)children memberType : (XcodeMemberType)groupType
44
+ {
45
+ return [[XCGroup alloc ]initWithProject:project key: key alias: alias path: path children: children memberType: groupType];
41
46
}
42
47
43
48
// -------------------------------------------------------------------------------------------
44
49
#pragma mark - Initialization & Destruction
45
50
// -------------------------------------------------------------------------------------------
46
51
47
- - (id )initWithProject : (XCProject *)project key : (NSString *)key alias : (NSString *)alias path : (NSString *)path
48
- children : (NSArray *)children
52
+ - (id )initWithProject : (XCProject *)project key : (NSString *)key alias : (NSString *)alias path : (NSString *)path children : (NSArray <id<XcodeGroupMember>> *)children memberType : (XcodeMemberType)groupType
49
53
{
50
54
self = [super init ];
55
+
56
+ assert (groupType == PBXGroupType || groupType == PBXVariantGroupType);
57
+
51
58
if (self) {
52
59
_project = project;
53
60
_fileOperationQueue = [_project fileOperationQueue ];
@@ -59,10 +66,18 @@ - (id)initWithProject:(XCProject *)project key:(NSString *)key alias:(NSString *
59
66
if (!_children) {
60
67
_children = [[NSMutableArray alloc ] init ];
61
68
}
69
+
70
+ _memberType = groupType;
62
71
}
63
72
return self;
64
73
}
65
74
75
+ - (id )initWithProject : (XCProject *)project key : (NSString *)key alias : (NSString *)alias path : (NSString *)path
76
+ children : (NSArray *)children
77
+ {
78
+ return [self initWithProject: project key: key alias: alias path: path children: children memberType: PBXGroupType];
79
+ }
80
+
66
81
// -------------------------------------------------------------------------------------------
67
82
#pragma mark - Interface Methods
68
83
// -------------------------------------------------------------------------------------------
@@ -276,7 +291,12 @@ - (XCGroup *)addGroupWithPath:(NSString *)path
276
291
return group;
277
292
}
278
293
279
- - (XCGroup*)addGroupWithAlias : (NSString *)alias
294
+ - (XCGroup *)addGroupWithAlias : (NSString *)alias
295
+ {
296
+ return [self addGroupWithAlias: alias groupType: PBXGroupType];
297
+ }
298
+
299
+ - (XCGroup*)addGroupWithAlias : (NSString *)alias groupType : (XcodeMemberType)type
280
300
{
281
301
NSString *groupKey = [[XCKeyBuilder forItemNamed: alias] build ];
282
302
@@ -290,7 +310,7 @@ - (XCGroup*)addGroupWithAlias:(NSString *)alias
290
310
}
291
311
}
292
312
293
- XCGroup *group = [[XCGroup alloc ] initWithProject: _project key: groupKey alias: alias path: nil children: nil ];
313
+ XCGroup *group = [[XCGroup alloc ] initWithProject: _project key: groupKey alias: alias path: nil children: nil memberType: type ];
294
314
NSDictionary *groupDict = [group asDictionary ];
295
315
296
316
[_project objects ][groupKey] = groupDict;
@@ -828,7 +848,7 @@ - (NSDictionary *)makeFileReferenceWithPath:(NSString *)path name:(NSString *)na
828
848
- (NSDictionary *)asDictionary
829
849
{
830
850
NSMutableDictionary *groupData = [NSMutableDictionary dictionary ];
831
- groupData[@" isa" ] = [NSString xce_stringFromMemberType: PBXGroupType ];
851
+ groupData[@" isa" ] = [NSString xce_stringFromMemberType: _memberType ];
832
852
groupData[@" sourceTree" ] = @" <group>" ;
833
853
834
854
if (_alias != nil ) {
@@ -859,4 +879,4 @@ - (void)addSourceFile:(XCSourceFile *)sourceFile toTargets:(NSArray *)targets
859
879
}
860
880
}
861
881
862
- @end
882
+ @end
0 commit comments