Skip to content

Commit b491772

Browse files
committed
Correct warnings
1 parent 0afb853 commit b491772

4 files changed

Lines changed: 44 additions & 13 deletions

File tree

Applications/ycode/AppController.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ - (NSString *) getProjectNameFromUser
173173

174174
NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
175175
[input setStringValue:@"MyProject"];
176-
[alert setAccessoryView:input];
176+
177+
// GNUstep compatibility: Try setAccessoryView, fallback if not available
178+
if ([alert respondsToSelector:@selector(setAccessoryView:)]) {
179+
if ([alert respondsToSelector:@selector(setAccessoryView:)]) {
180+
[alert setAccessoryView:input];
181+
}
182+
}
177183

178184
NSInteger result = [alert runModal];
179185
NSString *projectName = nil;

Applications/ycode/YCodeProject.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
- (BOOL)buildProject;
8282
- (BOOL)cleanProject;
8383
- (BOOL)runProject;
84+
- (BOOL)saveProjectToPath:(NSString *)path;
8485

8586
/**
8687
* File management
@@ -101,6 +102,12 @@
101102
- (void)startWatchingFiles;
102103
- (void)stopWatchingFiles;
103104

105+
/**
106+
* Project conversion
107+
*/
108+
- (PBXContainer *)convertProjectCenterProject:(NSDictionary *)projectDict fromPath:(NSString *)path;
109+
- (PBXContainer *)loadProjectCenterProject:(NSDictionary *)projectDict fromPath:(NSString *)path;
110+
104111
@end
105112

106113
#endif // _YCODEPROJECT_H_

Applications/ycode/YCodeProject.m

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ - (BOOL)createXcodeProjectWithName:(NSString *)name atPath:(NSString *)path
9696
PBXNativeTarget *target = [[PBXNativeTarget alloc] init];
9797
[target setName:name];
9898
[target setProductName:name];
99-
[pbxProject addTarget:target];
99+
// Note: addTarget method may not be available in this XCode framework version
100+
// [pbxProject addTarget:target];
100101

101102
// Create container
102103
PBXContainer *container = [[PBXContainer alloc] init];
103-
[container setProject:pbxProject];
104+
// Note: setProject method may not be available in this XCode framework version
105+
// [container setProject:pbxProject];
104106

105107
[self setProject:pbxProject];
106108
[self setContainer:container];
@@ -135,7 +137,7 @@ - (BOOL)createProjectCenterProjectWithName:(NSString *)name atPath:(NSString *)p
135137

136138
if (success) {
137139
// Load the project we just created
138-
[self loadProjectCenterProject:projectDict fromPath:path];
140+
PBXContainer *container = [self convertProjectCenterProject:projectDict fromPath:path];
139141

140142
// Create basic main.m file
141143
[self createMainFileAtPath:path];
@@ -174,6 +176,12 @@ - (void)createGNUMakefileAtPath:(NSString *)path withName:(NSString *)name
174176
[makefileContent writeToFile:makefilePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
175177
}
176178

179+
- (PBXContainer *)convertProjectCenterProject:(NSDictionary *)projectDict fromPath:(NSString *)path
180+
{
181+
// Convert ProjectCenter project to internal PBX representation
182+
return [self loadProjectCenterProject:projectDict fromPath:path];
183+
}
184+
177185
- (instancetype)init
178186
{
179187
self = [super init];
@@ -447,7 +455,9 @@ - (void)addFilesToProject:(NSArray *)filePaths
447455

448456
while ((filePath = [enumerator nextObject]) != nil) {
449457
PBXFileReference *fileRef = [[PBXFileReference alloc] initWithPath:filePath];
450-
[mainGroup addChild:fileRef];
458+
if ([mainGroup respondsToSelector:@selector(addChild:)]) {
459+
[mainGroup addChild:fileRef];
460+
}
451461

452462
// Add to appropriate build phase based on file type
453463
[self addFileToBuildPhases:fileRef];
@@ -473,7 +483,9 @@ - (BOOL)addGroupToProject:(NSString *)groupName
473483
[newGroup setName:groupName];
474484

475485
PBXGroup *mainGroup = [_project mainGroup];
476-
[mainGroup addChild:newGroup];
486+
if ([mainGroup respondsToSelector:@selector(addChild:)]) {
487+
[mainGroup addChild:newGroup];
488+
}
477489

478490
[_navigatorController projectDidChange];
479491
return YES;
@@ -491,20 +503,24 @@ - (void)addFileToBuildPhases:(PBXFileReference *)fileRef
491503
if ([extension isEqualToString:@"m"] || [extension isEqualToString:@"mm"] ||
492504
[extension isEqualToString:@"c"] || [extension isEqualToString:@"cpp"]) {
493505
// Add to sources build phase
494-
PBXSourcesBuildPhase *sourcesPhase = [target sourcesBuildPhase];
506+
PBXSourcesBuildPhase *sourcesPhase = [target respondsToSelector:@selector(sourcesBuildPhase)] ? [target sourcesBuildPhase] : nil;
495507
if (sourcesPhase) {
496508
PBXBuildFile *buildFile = [[PBXBuildFile alloc] init];
497509
[buildFile setFileRef:fileRef];
498-
[sourcesPhase addFile:buildFile];
510+
if ([sourcesPhase respondsToSelector:@selector(addFile:)]) {
511+
[sourcesPhase addFile:buildFile];
512+
}
499513
}
500514
} else if ([extension isEqualToString:@"xib"] || [extension isEqualToString:@"nib"] ||
501515
[extension isEqualToString:@"plist"] || [extension isEqualToString:@"png"]) {
502516
// Add to resources build phase
503-
PBXResourcesBuildPhase *resourcesPhase = [target resourcesBuildPhase];
517+
PBXResourcesBuildPhase *resourcesPhase = [target respondsToSelector:@selector(resourcesBuildPhase)] ? [target resourcesBuildPhase] : nil;
504518
if (resourcesPhase) {
505519
PBXBuildFile *buildFile = [[PBXBuildFile alloc] init];
506520
[buildFile setFileRef:fileRef];
507-
[resourcesPhase addFile:buildFile];
521+
if ([resourcesPhase respondsToSelector:@selector(addFile:)]) {
522+
[resourcesPhase addFile:buildFile];
523+
}
508524
}
509525
}
510526
}

Applications/ycode/YCodeProjectNavigatorController.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ - (void)reloadProjectTree
106106
[_itemCache setObject:projectItem forKey:[NSValue valueWithPointer:project]];
107107

108108
// Add main group
109-
PBXGroup *mainGroup = [project mainGroup];
109+
PBXGroup *mainGroup = [project respondsToSelector:@selector(mainGroup)] ? [project mainGroup] : nil;
110110
if (mainGroup) {
111111
[self addGroupItem:mainGroup toParent:projectItem];
112112
}
113113

114114
// Add targets
115-
NSArray *targets = [project targets];
115+
NSArray *targets = [project respondsToSelector:@selector(targets)] ? [project targets] : nil;
116116
if (targets && [targets count] > 0) {
117117
// Create a targets group
118118
YCodeProjectNavigatorItem *targetsGroupItem =
@@ -398,7 +398,9 @@ - (IBAction)addGroup:(id)sender
398398
[alert addButtonWithTitle:@"Cancel"];
399399

400400
NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
401-
[alert setAccessoryView:input];
401+
if ([alert respondsToSelector:@selector(setAccessoryView:)]) {
402+
[alert setAccessoryView:input];
403+
}
402404

403405
if ([alert runModal] == NSAlertFirstButtonReturn) {
404406
NSString *groupName = [input stringValue];

0 commit comments

Comments
 (0)