Skip to content

Commit 800366f

Browse files
author
jblues
committed
Add test resource.
1 parent d9cfcc8 commit 800366f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1778
-124
lines changed

.idea/XcodeEditor.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Tests.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ An API for manipulating Xcode project files.
99

1010
```objective-c
1111
XCProject* project = [[XCProject alloc] initWithFilePath:@"MyProject.xcodeproj"];
12-
XCGroup* group = [project groupWithPathFromRoot:@"Main"];
12+
XCGroup* _group = [project groupWithPathFromRoot:@"Main"];
1313
XCClassDefinition* classDefinition = [[XCClassDefinition alloc] initWithName:@"MyNewClass"];
1414
[classDefinition setHeader:@"<some-header-text>"];
1515
[classDefinition setSource:@"<some-impl-text>"];
1616

17-
[group addClass:classDefinition];
17+
[_group addClass:classDefinition];
1818
[project save];
1919
```
2020
@@ -44,7 +44,7 @@ This time, we'll use a convenience method on XCGroup to specify the targets at t
4444
4545
```objective-c
4646
XCXibDefinition* xibDefinition = [[XCXibDefinition alloc] initWithName:@"MyXibFile" content:@"<xibXml>"];
47-
[group addXib:xibDefinition toTargets:[project targets]];
47+
[_group addXib:xibDefinition toTargets:[project targets]];
4848
[project save];
4949
```
5050

@@ -54,10 +54,10 @@ XCXibDefinition* xibDefinition = [[XCXibDefinition alloc] initWithName:@"MyXibFi
5454
```objective-c
5555
XCFrameworkDefinition* frameworkDefinition =
5656
[[XCFrameworkDefinition alloc] initWithFilePath:@"<framework path>" copyToDestination:NO];
57-
[group addFramework:frameworkDefinition toTargets:[project targets]];
57+
[_group addFramework:frameworkDefinition toTargets:[project targets]];
5858
[project save];
5959
```
60-
Setting copyToDestination to YES, will cause the framework to be first copied to the group's directory within the
60+
Setting copyToDestination to YES, will cause the framework to be first copied to the _group's directory within the
6161
project, and subsequently linked from there.
6262
6363
### Adding an Image Resource
@@ -68,7 +68,7 @@ XCSourceFileDefinition* sourceFileDefinition = [[XCSourceFileDefinition alloc]
6868
initWithName:@"MyImageFile.png" data:[NSData dataWithContentsOfFile:<your image file name>]
6969
type:ImageResourcePNG];
7070
71-
[group addSourceFile:sourceFileDefinition];
71+
[_group addSourceFile:sourceFileDefinition];
7272
[project save];
7373
```
7474

@@ -78,7 +78,7 @@ XCSourceFileDefinition* sourceFileDefinition = [[XCSourceFileDefinition alloc]
7878

7979
XCSourceFileDefinition* sourceFileDefinition = [XCSourceFileDefinition sourceDefinitionWithAssetCatalogName:<path to asset catalog>];
8080

81-
[group addSourceFile:sourceFileDefinition];
81+
[_group addSourceFile:sourceFileDefinition];
8282
[project save];
8383
```
8484
@@ -88,20 +88,20 @@ XCSourceFileDefinition* sourceFileDefinition = [XCSourceFileDefinition sourceDef
8888
XCSourceFileDefinition* header = [[XCSourceFileDefinition alloc]
8989
initWithName:@"SomeHeader.h" text:<your header text> type:SourceCodeHeader];
9090
91-
[group addSourceFile:header];
91+
[_group addSourceFile:header];
9292
[project save];
9393
```
9494

9595
### Adding a sub-project
9696

9797
```objective-c
9898
subProjectDefinition = [XCSubProjectDefinition withName:@"mySubproject" projPath=@"/Path/To/Subproject" type:XcodeProject];
99-
[group addSubProject:subProjectDefinition toTargets:[project targets]];
99+
[_group addSubProject:subProjectDefinition toTargets:[project targets]];
100100
```
101101
102102
### Removing a sub-project
103103
```objective-c
104-
[group removeSubProject:subProjectDefinition]; //TODO: project should be able to remove itself from parent.
104+
[_group removeSubProject:subProjectDefinition]; //TODO: project should be able to remove itself from parent.
105105
```
106106

107107
### Configuring targets

Source/XCGroup.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
/**
28-
* Represents a group container in an Xcode project. A group can contain members of type `XCSourceFile` or other
28+
* Represents a _group container in an Xcode project. A _group can contain members of type `XCSourceFile` or other
2929
* groups.
3030
*/
3131
@interface XCGroup : NSObject <XcodeGroupMember>
@@ -48,21 +48,21 @@
4848

4949

5050
/**
51-
* The alias of the group, which can be used to give the group a name other than the last path component.
51+
* The alias of the _group, which can be used to give the _group a name other than the last path component.
5252
*
5353
* See: [XcodeGroupMember displayName]
5454
*/
5555
@property(nonatomic, strong, readonly) NSString* alias;
5656

5757
/**
58-
* The path of the group relative to the group's parent.
58+
* The path of the _group relative to the _group's parent.
5959
*
6060
* See: [XcodeGroupMember displayName]
6161
*/
6262
@property(nonatomic, strong, readonly) NSString* pathRelativeToParent;
6363

6464
/**
65-
* The group's unique key.
65+
* The _group's unique key.
6666
*/
6767
@property(nonatomic, strong, readonly) NSString* key;
6868

@@ -78,7 +78,7 @@
7878

7979
- (id)initWithProject:(XCProject*)project key:(NSString*)key alias:(NSString*)alias path:(NSString*)path children:(NSArray<id<XcodeGroupMember>>*)children;
8080

81-
#pragma mark Parent group
81+
#pragma mark Parent _group
8282

8383
- (void)removeFromParentGroup;
8484

@@ -90,24 +90,24 @@
9090

9191
#pragma mark Adding children
9292
/**
93-
* Adds a class to the group, as specified by the ClassDefinition. If the group already contains a class by the same
93+
* Adds a class to the _group, as specified by the ClassDefinition. If the _group already contains a class by the same
9494
* name, the contents will be updated.
9595
*/
9696
- (void)addClass:(XCClassDefinition*)classDefinition;
9797

9898
/**
99-
* Adds a class to the group, making it a member of the specified [targets](XCTarget).
99+
* Adds a class to the _group, making it a member of the specified [targets](XCTarget).
100100
*/
101101
- (void)addClass:(XCClassDefinition*)classDefinition toTargets:(NSArray<XCTarget*>*)targets;
102102

103103
/**
104-
* Adds a framework to the group. If the group already contains the framework, the contents will be updated if the
104+
* Adds a framework to the _group. If the _group already contains the framework, the contents will be updated if the
105105
* framework definition's copyToDestination flag is yes, otherwise it will be ignored.
106106
*/
107107
- (void)addFramework:(XCFrameworkDefinition*)frameworkDefinition;
108108

109109
/**
110-
* Adds a group with a path relative to this group.
110+
* Adds a _group with a path relative to this _group.
111111
*/
112112
- (XCGroup*)addGroupWithPath:(NSString*)path;
113113

@@ -117,7 +117,7 @@
117117
- (void)addFolderReference:(NSString*)sourceFolder;
118118

119119
/**
120-
* Adds a framework to the group, making it a member of the specified targets.
120+
* Adds a framework to the _group, making it a member of the specified targets.
121121
*/
122122
- (void)addFramework:(XCFrameworkDefinition*)framework toTargets:(NSArray<XCTarget*>*)targets;
123123

@@ -128,25 +128,25 @@
128128

129129

130130
/**
131-
* Adds a xib file to the group. If the group already contains a class by the same name, the contents will be updated.
131+
* Adds a xib file to the _group. If the _group already contains a class by the same name, the contents will be updated.
132132
*/
133133
- (void)addXib:(XCXibDefinition*)xibDefinition;
134134

135135
/**
136-
* Adds a xib to the group, making it a member of the specified [targets](XCTarget).
136+
* Adds a xib to the _group, making it a member of the specified [targets](XCTarget).
137137
*/
138138
- (void)addXib:(XCXibDefinition*)xibDefinition toTargets:(NSArray<XCTarget*>*)targets;
139139

140140
/**
141-
* Adds a sub-project to the group. If the group already contains a sub-project by the same name, the contents will be
141+
* Adds a sub-project to the _group. If the _group already contains a sub-project by the same name, the contents will be
142142
* updated.
143143
* Returns boolean success/fail; if method fails, caller should assume that project file is corrupt (or file format has
144144
* changed).
145145
*/
146146
- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition;
147147

148148
/**
149-
* Adds a sub-project to the group, making it a member of the specified [targets](XCTarget).
149+
* Adds a sub-project to the _group, making it a member of the specified [targets](XCTarget).
150150
*/
151151
- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition toTargets:(NSArray<XCTarget*>*)targets;
152152

@@ -162,12 +162,12 @@
162162
- (NSArray<id<XcodeGroupMember>>*)members;
163163

164164
/**
165-
* Keys of members from this group and any child groups.
165+
* Keys of members from this _group and any child groups.
166166
*/
167167
- (NSArray<NSString*>*)recursiveMembers;
168168

169169
/**
170-
* Keys of members from this group
170+
* Keys of members from this _group
171171
*/
172172
- (NSArray<NSString*>*)buildFileKeys;
173173

Source/XCGroup.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ - (id)initWithProject:(XCProject *)project key:(NSString *)key alias:(NSString *
6666
#pragma mark - Interface Methods
6767
//-------------------------------------------------------------------------------------------
6868

69-
#pragma mark Parent group
69+
#pragma mark Parent _group
7070

7171
- (void)removeFromParentGroup
7272
{
@@ -246,10 +246,10 @@ - (void)addXib:(XCXibDefinition *)xibDefinition toTargets:(NSArray *)targets
246246
// adds an xcodeproj as a subproject of the current project.
247247
- (void)addSubProject:(XCSubProjectDefinition *)projectDefinition
248248
{
249-
// set up path to the xcodeproj file as Xcode sees it - path to top level of project + group path if any
249+
// set up path to the xcodeproj file as Xcode sees it - path to top level of project + _group path if any
250250
[projectDefinition initFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]];
251251

252-
// create PBXFileReference for xcodeproj file and add to PBXGroup for the current group
252+
// create PBXFileReference for xcodeproj file and add to PBXGroup for the current _group
253253
// (will retrieve existing if already there)
254254
[self makeGroupMemberWithName:[projectDefinition projectFileName] path:[projectDefinition pathRelativeToProjectRoot]
255255
type:XcodeProject fileOperationStyle:[projectDefinition fileOperationType]];
@@ -284,18 +284,18 @@ - (void)removeSubProject:(XCSubProjectDefinition *)projectDefinition
284284
return;
285285
}
286286

287-
// set up path to the xcodeproj file as Xcode sees it - path to top level of project + group path if any
287+
// set up path to the xcodeproj file as Xcode sees it - path to top level of project + _group path if any
288288
[projectDefinition initFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]];
289289

290290
NSString *xcodeprojKey = [projectDefinition projectKey];
291291

292-
// Remove from group and remove PBXFileReference
292+
// Remove from _group and remove PBXFileReference
293293
[self removeGroupMemberWithKey:xcodeprojKey];
294294

295295
// remove PBXContainerItemProxies and PBXReferenceProxies
296296
[_project removeProxies:xcodeprojKey];
297297

298-
// get the key for the Products group
298+
// get the key for the Products _group
299299
NSString *productsGroupKey = [_project productsGroupKeyForKey:xcodeprojKey];
300300

301301
// remove from the ProjectReferences array of PBXProject
@@ -304,7 +304,7 @@ - (void)removeSubProject:(XCSubProjectDefinition *)projectDefinition
304304
// remove PDXBuildFile entries
305305
[self removeProductsGroupFromProject:productsGroupKey];
306306

307-
// remove Products group
307+
// remove Products _group
308308
[[_project objects] removeObjectForKey:productsGroupKey];
309309

310310
// remove from all targets
@@ -317,7 +317,7 @@ - (void)removeSubProject:(XCSubProjectDefinition *)projectDefinition fromTargets
317317
return;
318318
}
319319

320-
// set up path to the xcodeproj file as Xcode sees it - path to top level of project + group path if any
320+
// set up path to the xcodeproj file as Xcode sees it - path to top level of project + _group path if any
321321
[projectDefinition initFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]];
322322

323323
NSString *xcodeprojKey = [projectDefinition projectKey];
@@ -527,7 +527,7 @@ - (void)makeGroupMemberWithName:(NSString *)name contents:(id)contents type:(Xco
527527

528528
#pragma mark Xcodeproj methods
529529

530-
// creates PBXFileReference and adds to group if not already there; returns key for file reference. Locates
530+
// creates PBXFileReference and adds to _group if not already there; returns key for file reference. Locates
531531
// member via path rather than name, because that is how subprojects are stored by Xcode
532532
- (void)makeGroupMemberWithName:(NSString *)name path:(NSString *)path type:(XcodeSourceFileType)type
533533
fileOperationStyle:(XCFileOperationType)fileOperationStyle
@@ -541,7 +541,7 @@ - (void)makeGroupMemberWithName:(NSString *)name path:(NSString *)path type:(Xco
541541
}
542542
}
543543

544-
// makes a new group called Products and returns its key
544+
// makes a new _group called Products and returns its key
545545
- (NSString *)makeProductsGroup:(XCSubProjectDefinition *)xcodeprojDefinition
546546
{
547547
NSMutableArray *children = [NSMutableArray array];
@@ -557,7 +557,7 @@ - (NSString *)makeProductsGroup:(XCSubProjectDefinition *)xcodeprojDefinition
557557
return productKey;
558558
}
559559

560-
// makes a new Products group (by calling the method above), makes a new projectReferences array for it and
560+
// makes a new Products _group (by calling the method above), makes a new projectReferences array for it and
561561
// then adds it to the PBXProject object
562562
- (void)addProductsGroupToProject:(XCSubProjectDefinition *)xcodeprojDefinition
563563
{
@@ -578,7 +578,7 @@ - (void)addProductsGroupToProject:(XCSubProjectDefinition *)xcodeprojDefinition
578578
PBXProjectDict[@"projectReferences"] = projectReferences;
579579
}
580580

581-
// removes PBXFileReference from group and project
581+
// removes PBXFileReference from _group and project
582582
- (void)removeGroupMemberWithKey:(NSString *)key
583583
{
584584
NSMutableArray *children = [self valueForKey:@"children"];
@@ -611,7 +611,7 @@ - (void)removeBuildPhaseFileKey:(NSString *)key forType:(XcodeMemberType)memberT
611611
// removes entries from PBXBuildFiles, PBXFrameworksBuildPhase and PBXResourcesBuildPhase
612612
- (void)removeProductsGroupFromProject:(NSString *)key
613613
{
614-
// remove product group's build products from PDXBuildFiles
614+
// remove product _group's build products from PDXBuildFiles
615615
NSDictionary *productsGroup = _project.objects[key];
616616
for (NSString *childKey in [productsGroup valueForKey:@"children"]) {
617617
NSArray *buildFileKeys =
@@ -643,7 +643,7 @@ - (NSDictionary *)makeFileReferenceWithPath:(NSString *)path name:(NSString *)na
643643
if (path != nil) {
644644
reference[@"path"] = path;
645645
}
646-
reference[@"sourceTree"] = @"<group>";
646+
reference[@"sourceTree"] = @"<_group>";
647647
return reference;
648648
}
649649

@@ -652,7 +652,7 @@ - (NSDictionary *)asDictionary
652652
{
653653
NSMutableDictionary *groupData = [NSMutableDictionary dictionary];
654654
groupData[@"isa"] = [NSString xce_stringFromMemberType:PBXGroupType];
655-
groupData[@"sourceTree"] = @"<group>";
655+
groupData[@"sourceTree"] = @"<_group>";
656656

657657
if (_alias != nil) {
658658
groupData[@"name"] = _alias;

Source/XCProject+SubProject.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ - (void)removeProxies:(NSString *)xcodeprojKey
311311
}];
312312
}
313313

314-
// returns the Products group key for the given PBXFileReference key, nil if not found.
314+
// returns the Products _group key for the given PBXFileReference key, nil if not found.
315315
- (NSString *)productsGroupKeyForKey:(NSString *)key
316316
{
317317
NSMutableArray *projectReferences = [[self PBXProjectDict] valueForKey:@"projectReferences"];

Source/XCProject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
- (NSArray<XCGroup*>*)groups;
105105

106106
/**
107-
* Returns the root (top-level) group.
107+
* Returns the root (top-level) _group.
108108
*/
109109
- (XCGroup*)rootGroup;
110110

@@ -114,22 +114,22 @@
114114
- (NSArray<XCGroup*>*)rootGroups;
115115

116116
/**
117-
* Returns the group with the given key, or nil.
117+
* Returns the _group with the given key, or nil.
118118
*/
119119
- (XCGroup*)groupWithKey:(NSString*)key;
120120

121121
/**
122-
* Returns the group with the specified display name path - the directory relative to the root group. Eg Source/Main
122+
* Returns the _group with the specified display name path - the directory relative to the root _group. Eg Source/Main
123123
*/
124124
- (XCGroup*)groupWithPathFromRoot:(NSString*)path;
125125

126126
/**
127-
* Returns the parent group for the group or file with the given key;
127+
* Returns the parent _group for the _group or file with the given key;
128128
*/
129129
- (XCGroup*)groupForGroupMemberWithKey:(NSString*)key;
130130

131131
/**
132-
* Returns the parent group for the group or file with the source file
132+
* Returns the parent _group for the _group or file with the source file
133133
*/
134134
- (XCGroup*)groupWithSourceFile:(XCSourceFile*)sourceFile;
135135

0 commit comments

Comments
 (0)