@@ -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 }
0 commit comments