@@ -227,21 +227,55 @@ - (NSMutableDictionary *) configToInfoPlist: (XCBuildConfiguration *)config
227227 [ipd setObject: @" $(DEVELOPMENT_LANGUAGE)" forKey: @" CFBundleDevelopmentRegion" ];
228228 [ipd setObject: @" $(EXECUTABLE_NAME)" forKey: @" CFBundlExecutable" ];
229229 [ipd setObject: bundleIdentifier forKey: @" CFBundleIdentifier" ];
230-
230+
231231 return ipd;
232232}
233233
234+ - (NSString *) generateInfoPlistOutput : (NSString *)outputPlist
235+ {
236+ GSXCBuildContext *context = [GSXCBuildContext sharedBuildContext ];
237+ // NSString *productOutputDir = [context objectForKey: @"PRODUCT_OUTPUT_DIR"];
238+ NSDictionary *ctx = [context currentContext ];
239+ XCConfigurationList *xcl = [ctx objectForKey: @" buildConfig" ];
240+ XCBuildConfiguration *xbc = [xcl defaultConfiguration ];
241+ NSDictionary *bs = [xbc buildSettings ];
242+ NSString *infoPlist = [bs objectForKey: @" INFOPLIST_FILE" ];
243+ NSFileManager *mgr = [NSFileManager defaultManager ];
244+ NSString *pl = nil ;
245+
246+ if (infoPlist != nil )
247+ {
248+ if ([mgr fileExistsAtPath: infoPlist] == NO )
249+ {
250+ infoPlist = [infoPlist lastPathComponent ];
251+ }
252+
253+ [self processInfoPlistInput: infoPlist
254+ output: outputPlist];
255+ }
256+ else
257+ {
258+ xcputs ([[NSString stringWithFormat: @" \t * Generating info plist --> %s %@ %s " , GREEN, outputPlist, RESET] cString ]);
259+ XCBuildConfiguration *config = [xcl configurationWithName: @" Debug" ];
260+ NSMutableDictionary *ipl = [self configToInfoPlist: config];
261+ pl = [ipl description ];
262+ }
263+
264+ return pl;
265+ }
266+
234267- (BOOL ) build
235268{
236- xcputs (" === Executing Resources Build Phase" );
237269 NSFileManager *mgr = [NSFileManager defaultManager ];
238270 GSXCBuildContext *context = [GSXCBuildContext sharedBuildContext ];
239- NSString *productOutputDir = [context objectForKey: @" PRODUCT_OUTPUT_DIR" ]; // [NSString stringWithCString: getenv("PRODUCT_OUTPUT_DIR")];
271+ NSString *productOutputDir = [context objectForKey: @" PRODUCT_OUTPUT_DIR" ];
240272 NSString *resourcesDir = [productOutputDir stringByAppendingPathComponent: @" Resources" ];
273+ NSString *outputPlist = [resourcesDir stringByAppendingPathComponent: @" Info-gnustep.plist" ];
241274 NSError *error = nil ;
242- NSString *productName = [self productName ]; // @""; // [_target productName];
275+ NSString *productName = [self productName ];
243276
244277 NSDebugLog (@" productName = %@ " , productName);
278+ xcputs (" === Executing Resources Build Phase" );
245279
246280 // Pre create directory....
247281 [mgr createDirectoryAtPath: resourcesDir
@@ -250,7 +284,7 @@ - (BOOL) build
250284 error: &error];
251285
252286 // Copy all resources...
253- NSArray *files = [self allFiles ];
287+ NSArray *files = [self allFiles ];
254288 NSEnumerator *en = [files objectEnumerator ];
255289 BOOL result = YES ;
256290 id file = nil ;
@@ -349,35 +383,13 @@ - (BOOL) build
349383 }
350384
351385 // Handle Info.plist....
352- NSDictionary *ctx = [context currentContext ];
353- XCConfigurationList *xcl = [ctx objectForKey: @" buildConfig" ];
354- XCBuildConfiguration *xbc = [xcl defaultConfiguration ];
355- NSDictionary *bs = [xbc buildSettings ];
356- NSString *infoPlist = [bs objectForKey: @" INFOPLIST_FILE" ];
357- NSString *outputPlist = [resourcesDir
358- stringByAppendingPathComponent: @" Info-gnustep.plist" ];
359-
360- if (infoPlist != nil )
386+ NSString *pl = [self generateInfoPlistOutput: outputPlist];
387+ BOOL f = [pl writeToFile: outputPlist atomically: YES ];
388+ if (f == NO )
361389 {
362- if ([mgr fileExistsAtPath: infoPlist] == NO )
363- {
364- infoPlist = [infoPlist lastPathComponent ];
365- }
366-
367- [self processInfoPlistInput: infoPlist
368- output: outputPlist];
369- }
370- else
371- {
372- xcputs ([[NSString stringWithFormat: @" \t * Generating info plist --> %s %@ %s " , GREEN, outputPlist, RESET] cString ]);
373- XCBuildConfiguration *config = [xcl configurationWithName: @" Debug" ];
374- NSMutableDictionary *ipl = [self configToInfoPlist: config];
375- NSString *plString = [ipl description ];
376-
377- NSDebugLog (@" ipl = %@ " , ipl);
378- [plString writeToFile: outputPlist atomically: YES ];
390+ NSLog (@" ERROR: Issue writing out plist file" );
379391 }
380-
392+
381393 xcputs (" === Resources Build Phase Completed" );
382394 fflush (stdout);
383395
@@ -394,7 +406,7 @@ - (NSArray *) allFiles
394406- (BOOL ) generate
395407{
396408 GSXCBuildContext *context = [GSXCBuildContext sharedBuildContext ];
397-
409+
398410 // Use the new allFiles method to include files from groups
399411 NSArray *allFiles = [self allFiles ];
400412 NSMutableArray *resources = [NSMutableArray arrayWithCapacity: [allFiles count ]];
@@ -411,32 +423,32 @@ - (BOOL) generate
411423 while ((file = [en nextObject ]) != nil && result)
412424 {
413425 id fileRef = [file fileRef ];
414-
426+
415427 // Skip source code files - they should not be treated as resources
416428 if ([file respondsToSelector: @selector (fileRef )])
417- {
418- PBXFileReference *fr = [file fileRef ];
419- if (fr != nil && [fr respondsToSelector: @selector (path )])
420- {
421- NSString *path = [fr path ];
422- NSString *ext = [[path pathExtension ] lowercaseString ];
423-
424- // Skip common source code file extensions
425- if ([ext isEqualToString: @" m" ] ||
426- [ext isEqualToString: @" mm" ] ||
427- [ext isEqualToString: @" c" ] ||
428- [ext isEqualToString: @" cc" ] ||
429- [ext isEqualToString: @" cpp" ] ||
430- [ext isEqualToString: @" cxx" ] ||
431- [ext isEqualToString: @" swift" ])
432- {
433- // Skip this source file
434- xcputs ([[NSString stringWithFormat: @" \t Skipping source file: %@ " , path] cString ]);
435- continue ;
436- }
437- }
438- }
439-
429+ {
430+ PBXFileReference *fr = [file fileRef ];
431+ if (fr != nil && [fr respondsToSelector: @selector (path )])
432+ {
433+ NSString *path = [fr path ];
434+ NSString *ext = [[path pathExtension ] lowercaseString ];
435+
436+ // Skip common source code file extensions
437+ if ([ext isEqualToString: @" m" ] ||
438+ [ext isEqualToString: @" mm" ] ||
439+ [ext isEqualToString: @" c" ] ||
440+ [ext isEqualToString: @" cc" ] ||
441+ [ext isEqualToString: @" cpp" ] ||
442+ [ext isEqualToString: @" cxx" ] ||
443+ [ext isEqualToString: @" swift" ])
444+ {
445+ // Skip this source file
446+ xcputs ([[NSString stringWithFormat: @" \t Skipping source file: %@ " , path] cString ]);
447+ continue ;
448+ }
449+ }
450+ }
451+
440452 if ([fileRef isKindOfClass: [PBXVariantGroup class ]])
441453 {
442454 NSArray *children = [fileRef children ];
@@ -469,6 +481,7 @@ - (BOOL) generate
469481 }
470482
471483 // Handle Info.plist...
484+ /*
472485 NSDictionary *ctx = [context currentContext];
473486 XCConfigurationList *xcl = [ctx objectForKey: @"buildConfig"];
474487 XCBuildConfiguration *xbc = [xcl defaultConfiguration];
@@ -478,11 +491,18 @@ - (BOOL) generate
478491 {
479492 inputPlist = [inputPlist lastPathComponent];
480493 }
481-
494+ */
482495
483496 NSString *outputPlist = [NSString stringWithFormat: @" %@ Info.plist" ,appName] ;
484- [self processInfoPlistInput: inputPlist
485- output: outputPlist];
497+ // [self processInfoPlistInput: inputPlist
498+ // output: outputPlist];
499+ NSString *pl = [self generateInfoPlistOutput: outputPlist];
500+ BOOL f = [pl writeToFile: outputPlist atomically: YES ];
501+ if (f == NO )
502+ {
503+ NSLog (@" ERROR: Issue writing out plist file" );
504+ }
505+
486506
487507 // Move Base.lproj to English.lproj until Base.lproj is supported..
488508 // NSString *baseLproj = @"Base.lproj/*";
@@ -502,7 +522,7 @@ - (NSArray *) filesFromGroups
502522 // For now, return empty array since resources are typically explicitly
503523 // added to the resources build phase, not automatically discovered from
504524 // synchronized groups. Synchronized groups are primarily for source files.
505- //
525+ //
506526 // If we need to support resource files from synchronized groups in the future,
507527 // we would need to filter them to exclude source code files here as well.
508528 return [NSArray array ];
0 commit comments