Skip to content

Commit defa009

Browse files
committed
Add headers
1 parent 08e2e26 commit defa009

File tree

3 files changed

+83
-17
lines changed

3 files changed

+83
-17
lines changed

XCode/PBXFileReference.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ + (NSString *) fileTypeFromPath: (NSString *)path
9393
{
9494
result = @"text.plist.entitlements";
9595
}
96+
else if ([ext isEqualToString: @"h"])
97+
{
98+
result = @"sourcecode.c.h";
99+
}
96100

97101
return result;
98102
}
@@ -145,6 +149,10 @@ + (NSString *) extForFileType: (NSString *)type
145149
{
146150
result = @"entitlements";
147151
}
152+
else if ([type isEqualToString: @"sourcecode.c.h"])
153+
{
154+
result = @"h";
155+
}
148156

149157
return result;
150158
}
@@ -912,7 +920,7 @@ - (BOOL) generate
912920
NSMutableArray *objcFiles = [self _arrayForKey: @"OBJC_FILES"];
913921
NSMutableArray *cFiles = [self _arrayForKey: @"C_FILES"];
914922
NSMutableArray *cppFiles = [self _arrayForKey: @"CPP_FILES"];
915-
// NSMutableArray *hFiles = [self _arrayForKey: @"HEADERS"];
923+
NSMutableArray *hFiles = [self _arrayForKey: @"HEADERS"];
916924
NSMutableArray *objcppFiles = [self _arrayForKey: @"OBJCPP_FILES"];
917925
NSMutableArray *addlIncDirs = [self _arrayForKey: @"ADDITIONAL_INCLUDE_DIRS"];
918926
NSString *of = [context objectForKey: @"OUTPUT_FILES"];
@@ -1039,7 +1047,7 @@ - (BOOL) generate
10391047

10401048
if ([_lastKnownFileType isEqualToString: @"sourcecode.c.h"])
10411049
{
1042-
1050+
[hFiles addObject: compilePath];
10431051
}
10441052

10451053
NSString *includePath = [compilePath stringByDeletingLastPathComponent];

XCode/PBXResourcesBuildPhase.h

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,97 @@
2828
#import "PBXCoder.h"
2929
#import "PBXBuildPhase.h"
3030

31+
// Forward declarations
32+
@class XCBuildConfiguration;
33+
3134
@interface PBXResourcesBuildPhase : PBXBuildPhase
3235

33-
// Icon discovery methods
36+
/**
37+
* Discovers the app icon filename from the Assets.xcassets directory.
38+
* Searches for a 32x32@1x icon in the AppIcon.appiconset Contents.json file.
39+
* Returns the filename of the discovered app icon, or nil if none found.
40+
*/
3441
- (NSString *) discoverAppIcon;
42+
43+
/**
44+
* Discovers the full path to the app icon file.
45+
* Combines the Assets.xcassets directory path with the discovered icon filename.
46+
* Returns the complete path to the app icon file, or nil if no icon is found.
47+
*/
3548
- (NSString *) discoverAppIconPath;
49+
50+
/**
51+
* Copies the specified icon file from Assets.xcassets to the resources directory.
52+
* Creates the resources directory if it doesn't exist and handles file overwriting.
53+
* Takes the name of the icon file to copy as parameter.
54+
* Returns YES if the copy operation succeeded, NO otherwise.
55+
*/
3656
- (BOOL) copyAppIconToResources: (NSString *)iconFilename;
3757

38-
// Helper methods
58+
/**
59+
* Escapes special characters in filenames for makefile compatibility.
60+
* Handles spaces, dollar signs, hash symbols, and colons that have special
61+
* meaning in makefiles. Takes the filename to escape as parameter.
62+
* Returns the escaped filename suitable for use in makefiles, or nil if input is nil.
63+
*/
3964
- (NSString *) escapeFilenameForMakefile: (NSString *)filename;
4065

41-
// Info.plist generation methods
66+
/**
67+
* Generates Info.plist content for the application.
68+
* Creates a property list dictionary with application metadata.
69+
* Takes the name of the output plist file as parameter.
70+
* Returns the generated Info.plist content as a string.
71+
*/
4272
- (NSString *) generateInfoPlistOutput: (NSString *)outputPlist;
73+
74+
/**
75+
* Generates Info.plist content with app icon information.
76+
* Creates a property list dictionary including the specified icon file reference.
77+
* Takes the name of the output plist file and the name of the icon file as parameters.
78+
* Returns the generated Info.plist content as a string.
79+
*/
4380
- (NSString *) generateInfoPlistOutput: (NSString *)outputPlist withIconFile: (NSString *)iconFile;
81+
82+
/**
83+
* Converts build configuration to Info.plist dictionary.
84+
* Extracts relevant settings from the build configuration for plist generation.
85+
* Takes the build configuration to process as parameter.
86+
* Returns a mutable dictionary containing plist key-value pairs.
87+
*/
4488
- (NSMutableDictionary *) configToInfoPlist: (XCBuildConfiguration *)config;
89+
90+
/**
91+
* Converts build configuration to Info.plist dictionary with icon information.
92+
* Extracts settings and includes icon file reference in the generated dictionary.
93+
* Takes the build configuration to process and the name of the icon file as parameters.
94+
* Returns a mutable dictionary containing plist key-value pairs including icon info.
95+
*/
4596
- (NSMutableDictionary *) configToInfoPlist: (XCBuildConfiguration *)config withIconFile: (NSString *)iconFile;
97+
98+
/**
99+
* Processes an input Info.plist file and generates output with variable substitution.
100+
* Reads an existing plist file and performs environment variable substitution.
101+
* Takes the path to the input plist file and the path where the processed plist should be written as parameters.
102+
* Returns YES if processing succeeded, NO otherwise.
103+
*/
46104
- (BOOL) processInfoPlistInput: (NSString *)inputFileName
47105
output: (NSString *)outputFileName;
106+
107+
/**
108+
* Processes an input Info.plist file with icon information and generates output.
109+
* Reads an existing plist file, performs variable substitution, and adds icon info.
110+
* Takes the path to the input plist file, the path where the processed plist should be written,
111+
* and the name of the icon file to include as parameters.
112+
* Returns YES if processing succeeded, NO otherwise.
113+
*/
48114
- (BOOL) processInfoPlistInput: (NSString *)inputFileName
49115
output: (NSString *)outputFileName
50116
withIconFile: (NSString *)iconFileName;
51117

52-
// Legacy method (backward compatibility)
118+
/**
119+
* Legacy method for backward compatibility.
120+
* Processes assets and returns the discovered icon filename.
121+
*/
53122
- (NSString *) processAssets;
54123

55124
@end

XCode/PBXResourcesBuildPhase.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,8 @@ - (NSString *) productName
6161
NSDictionary *bs = [xbc buildSettings];
6262
NSString *productName = [bs objectForKey: @"PRODUCT_NAME"];
6363

64-
// NSProcessInfo *info = [NSProcessInfo processInfo];
65-
// NSDictionary *env = [info environment];
6664
NSDebugLog(@"bs = %@", bs);
6765

68-
// This is kind of a kludge, but better than what was here before.
69-
// I believe that when the context has the variable name it means to use
70-
// the product name from the target.
7166
if ([productName isEqualToString: @"$(TARGET_NAME)"])
7267
{
7368
productName = [_target productName];
@@ -327,7 +322,6 @@ - (NSMutableDictionary *) configToInfoPlist: (XCBuildConfiguration *)config with
327322
{
328323
NSMutableDictionary *ipd = [NSMutableDictionary dictionary];
329324
NSDictionary *buildSettings = [config buildSettings];
330-
// NSString *appIcon = [buildSettings objectForKey: @"ASSETCATALOG_COMPILER_APPICON_NAME"];
331325
NSString *version = [buildSettings objectForKey: @"CURRENT_PROJECT_VERSION"];
332326
NSString *copyright = [buildSettings objectForKey: @"INFOPLIST_KEY_NSHumanReadableCopyright"];
333327
NSString *mainNib = [buildSettings objectForKey: @"INFOPLIST_KEY_NSMainNibFile"];
@@ -352,7 +346,6 @@ - (NSMutableDictionary *) configToInfoPlist: (XCBuildConfiguration *)config with
352346
- (NSString *) generateInfoPlistOutput: (NSString *)outputPlist withIconFile: (NSString *)iconFile
353347
{
354348
GSXCBuildContext *context = [GSXCBuildContext sharedBuildContext];
355-
// NSString *productOutputDir = [context objectForKey: @"PRODUCT_OUTPUT_DIR"];
356349
NSDictionary *ctx = [context currentContext];
357350
XCConfigurationList *xcl = [ctx objectForKey: @"buildConfig"];
358351
XCBuildConfiguration *xbc = [xcl defaultConfiguration];
@@ -650,10 +643,6 @@ - (BOOL) generate
650643
}
651644

652645

653-
// Move Base.lproj to English.lproj until Base.lproj is supported..
654-
// NSString *baseLproj = @"Base.lproj/*";
655-
// NSString *engLproj = @"English.lproj";
656-
// [resources addObject: engLproj];
657646
NSString *escapedOutputPlist = [self escapeFilenameForMakefile: outputPlist];
658647
[resources addObject: escapedOutputPlist];
659648

0 commit comments

Comments
 (0)