forked from SquaredTiki/Xcode-Project-Reader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXcodeProjReaderAppDelegate.m
More file actions
166 lines (142 loc) · 5.31 KB
/
Copy pathXcodeProjReaderAppDelegate.m
File metadata and controls
166 lines (142 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//
// XcodeProjReaderAppDelegate.m
// XcodeProjReader
//
// Created by Joshua Garnham on 08/05/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "XcodeProjReaderAppDelegate.h"
@implementation XcodeProjReaderAppDelegate
@synthesize window;
#pragma mark -
#pragma mark Application Lifecycle
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
- (IBAction)browseForXcodeProject:(id)sender {
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setAllowsMultipleSelection:NO];
[oPanel setAllowedFileTypes:[NSArray arrayWithObject:@"xcodeproj"]];
[oPanel beginSheetModalForWindow:window completionHandler:^(NSInteger result) {
if (result == NSOKButton) {
NSArray *selectedFiles = [oPanel URLs];
NSURL *selectedFile = [selectedFiles objectAtIndex:0];
filePath = [[selectedFile path] retain];
[projLocField setStringValue:filePath];
[parseButton setEnabled:YES];
} else {
[parseButton setEnabled:NO];
}
}];
}
- (IBAction)parseCurrentlyLocatedXcodeProject:(id)sender {
projectCoordinator = [[[XCDProjectCoordinator alloc] initWithProjectAtPath:filePath] retain];
[projectCoordinator parseXcodeProject];
[outlineView reloadData];
}
#pragma mark -
#pragma mark Adding and Removing Items
- (IBAction)remove:(id)sender {
id item = [outlineView itemAtRow:[outlineView selectedRow]];
NSString *uuid = [item objectForKey:@"uuid"];
[projectCoordinator removeItemWithUUID:uuid];
[self parseCurrentlyLocatedXcodeProject:self];
/* NSLog(@"TEMPORARY OVERIDE");
NSString *path = @"/Users/joshuagarnham/Desktop/MyApp/MyApp.xcodeproj";
NSArray *frameworks = [NSArray arrayWithObjects:@"UIKit.framework", @"Foundation.framework", @"CoreGraphics.framework", nil];
NSArray *sourceFiles = [NSArray arrayWithObjects:@"MainViewController.h", @"MainViewController.m", @"MainViewController.xib", nil];
NSArray *supportingFiles = [NSArray arrayWithObjects:@"MyApp-Info.plist", @"InfoPlist.strings", @"main.m", @"MyApp-Prefix.pch", nil];
NSString *iOSVersion = @"4.2.1";
BOOL success = [self newProjectAtPath:path withFrameworks:frameworks sourceFiles:sourceFiles supportingFiles:supportingFiles oniOSVersion:iOSVersion];
if (!success) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"Error creating project"];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
} */
}
- (IBAction)addGroup:(id)sender {
NSString *title = [newGroupTitleField stringValue];
int selectedItemRow = [outlineView selectedRow];
NSString *uuid;
if (selectedItemRow >= 0) {
id selectedItem = [outlineView itemAtRow:selectedItemRow];
uuid = [selectedItem objectForKey:@"uuid"];
} else {
uuid = nil;
}
BOOL success = [projectCoordinator addGroupWithTitle:title toItemWithUUID:uuid];
[self parseCurrentlyLocatedXcodeProject:self];
if (!success) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"Error adding item"];
[alert setInformativeText:@"A new group could not be added likely because no title was entered or the item was trying to be added to a file."];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
}
}
- (IBAction)add:(id)sender {
NSString *title = [newItemTitleField stringValue];
int selectedItemRow = [outlineView selectedRow];
NSString *uuid;
if (selectedItemRow >= 0) {
id selectedItem = [outlineView itemAtRow:selectedItemRow];
uuid = [selectedItem objectForKey:@"uuid"];
} else {
uuid = nil;
}
BOOL success = [projectCoordinator addFileWithRelativePath:title asChildToItemWithUUID:uuid];
[self parseCurrentlyLocatedXcodeProject:self];
if (!success) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"Error adding item"];
[alert setInformativeText:@"A new item could not be added likely because no title was entered or the item was trying to be added to a file."];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
}
}
#pragma mark -
#pragma mark Outline View Delegate
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {
if ([item objectForKey:@"parent"] == nil)
return YES;
return NO;
}
#pragma mark -
#pragma mark Outline View Datasource
-(BOOL)outlineView:(NSOutlineView *)ov isItemExpandable:(id)item {
id children;
if (!item) {
children=projectCoordinator.files;
} else {
children=[item objectForKey:@"children"];
}
if ((!children) || ([children count]<1)) return NO;
return YES;
}
-(int)outlineView:(NSOutlineView *)ov numberOfChildrenOfItem:(id)item {
id children;
if (!item) {
children=projectCoordinator.files;
} else {
children=[item objectForKey:@"children"];
}
return [children count];
}
-(id)outlineView:(NSOutlineView *)ov child:(int)index ofItem:(id)item {
id children;
if (!item) {
children=projectCoordinator.files;
} else {
children=[item objectForKey:@"children"];
}
if ((!children) || ([children count]<=index)) return nil;
return [children objectAtIndex:index];
}
-(id)outlineView:(NSOutlineView *)ov objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
return [item valueForKey:tableColumn.identifier];
}
@end