Skip to content

Commit 339d6ab

Browse files
committed
Filter resource files
1 parent 52328cd commit 339d6ab

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

XCode/PBXResourcesBuildPhase.m

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,32 @@ - (BOOL) generate
406406
while((file = [en nextObject]) != nil && result)
407407
{
408408
id fileRef = [file fileRef];
409+
410+
// Skip source code files - they should not be treated as resources
411+
if ([file respondsToSelector: @selector(fileRef)])
412+
{
413+
PBXFileReference *fr = [file fileRef];
414+
if (fr != nil && [fr respondsToSelector: @selector(path)])
415+
{
416+
NSString *path = [fr path];
417+
NSString *ext = [[path pathExtension] lowercaseString];
418+
419+
// Skip common source code file extensions
420+
if ([ext isEqualToString: @"m"] ||
421+
[ext isEqualToString: @"mm"] ||
422+
[ext isEqualToString: @"c"] ||
423+
[ext isEqualToString: @"cc"] ||
424+
[ext isEqualToString: @"cpp"] ||
425+
[ext isEqualToString: @"cxx"] ||
426+
[ext isEqualToString: @"swift"])
427+
{
428+
// Skip this source file
429+
xcputs([[NSString stringWithFormat: @"\tSkipping source file: %@", path] cString]);
430+
continue;
431+
}
432+
}
433+
}
434+
409435
if ([fileRef isKindOfClass: [PBXVariantGroup class]])
410436
{
411437
NSArray *children = [fileRef children];
@@ -465,31 +491,16 @@ - (BOOL) generate
465491
return result;
466492
}
467493

468-
// Override filesFromGroups for resources - could include any file type
494+
// Override filesFromGroups for resources - exclude source code files
469495
- (NSArray *) filesFromGroups
470496
{
471-
NSMutableArray *result = [NSMutableArray array];
472-
473-
if (_target != nil)
474-
{
475-
// Resources can include both source and header files, plus other resource types
476-
// For now, we get both synchronized sources and headers
477-
NSArray *synchronizedSources = [_target synchronizedSources];
478-
if (synchronizedSources != nil)
479-
{
480-
[result addObjectsFromArray: synchronizedSources];
481-
}
482-
483-
NSArray *synchronizedHeaders = [_target synchronizedHeaders];
484-
if (synchronizedHeaders != nil)
485-
{
486-
[result addObjectsFromArray: synchronizedHeaders];
487-
}
488-
489-
// TODO: Could extend this to handle other resource types from groups
490-
}
491-
492-
return result;
497+
// For now, return empty array since resources are typically explicitly
498+
// added to the resources build phase, not automatically discovered from
499+
// synchronized groups. Synchronized groups are primarily for source files.
500+
//
501+
// If we need to support resource files from synchronized groups in the future,
502+
// we would need to filter them to exclude source code files here as well.
503+
return [NSArray array];
493504
}
494505

495506
- (BOOL) link

0 commit comments

Comments
 (0)