Skip to content

Commit 36d2cea

Browse files
committed
Add comprehensive Xcode file type UTIs
Expand FILE_TYPES_BY_EXTENSION with many additional file extensions and their Xcode UTIs (derived from Xcode built-in file type specs) and add a much larger FileType union in src/json/types.ts. Also include documentation comments and an escape-hatch type (string & {}) for unknown UTIs. A few existing mappings were adjusted to better match Xcode conventions (e.g., bundle, markdown, mdimporter). These changes improve extension handling and align project types with Xcode specs.
1 parent d988c06 commit 36d2cea

2 files changed

Lines changed: 423 additions & 44 deletions

File tree

src/api/utils/constants.ts

Lines changed: 244 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,283 @@ export const LAST_UPGRADE_CHECK = "1600";
3434
/** The last known Swift upgrade version to Xcodeproj. */
3535
export const LAST_SWIFT_UPGRADE_CHECK = "1600";
3636

37-
// The known file types corresponding to each extension.
37+
/**
38+
* The known file types corresponding to each extension.
39+
*
40+
* Derived from Xcode's built-in file type specs:
41+
* - DevToolsCore.framework/Versions/A/Resources/BuiltInFileTypes.xcspec
42+
* - DevToolsCore.framework/Versions/A/Resources/StandardFileTypes.xcspec
43+
* - Core Data.xcplugin/Contents/Resources/Core Data.pbfilespec
44+
* - CoreBuildTasks.xcplugin/Contents/Resources/InstrumentsPackage.xcspec
45+
* - Intents.xcplugin/Contents/Resources/Intents.pbfilespec
46+
* - Metal.xcplugin/Contents/Resources/FileTypes.xcspec
47+
* - RCBuildSystemSupport.xcplugin/Contents/Resources/RCFileTypes.pbfilespec
48+
* - SceneKit.xcplugin/Contents/Resources/SceneKit FileTypes.xcspec
49+
* - SpriteKit.xcplugin/Contents/Resources/SpriteKitFileTypes.xcspec
50+
* - XCLanguageSupport.xcplugin/Contents/Resources/Swift.pbfilespec
51+
*/
3852
export const FILE_TYPES_BY_EXTENSION: Record<string, json.FileType> =
3953
Object.freeze({
54+
"1": "text.man",
55+
C: "sourcecode.cpp.cpp",
56+
H: "sourcecode.cpp.h",
57+
M: "sourcecode.cpp.objcpp",
4058
a: "archive.ar",
59+
ada: "sourcecode.ada",
60+
adb: "sourcecode.ada",
61+
ads: "sourcecode.ada",
62+
aiff: "audio.aiff",
63+
air: "compiled.air",
64+
apinotes: "text.apinotes",
4165
apns: "text",
4266
app: "wrapper.application",
4367
// NOTE: This could also be `wrapper.extensionkit-extension`
4468
appex: "wrapper.app-extension",
45-
bundle: "wrapper.plug-in",
69+
applescript: "sourcecode.applescript",
70+
archivingdescription: "text.xml.ibArchivingDescription",
71+
asdictionary: "archive.asdictionary",
72+
asm: "sourcecode.asm.asm",
73+
atlas: "folder.skatlas",
74+
au: "audio.au",
75+
avi: "video.avi",
76+
bazel: "text.script.python",
77+
bin: "archive.macbinary",
78+
bmp: "image.bmp",
79+
bundle: "wrapper.cfbundle",
80+
bzl: "text.script.python",
81+
c: "sourcecode.c.c",
82+
"c++": "sourcecode.cpp.cpp",
83+
cc: "sourcecode.cpp.cpp",
84+
cdda: "audio.aiff",
85+
cl: "sourcecode.opencl",
86+
class: "compiled.javaclass",
87+
classdescription: "text.plist.ibClassDescription",
88+
classdescriptions: "text.plist.ibClassDescription",
89+
clp: "sourcecode.clips",
90+
cp: "sourcecode.cpp.cpp",
4691
cpp: "sourcecode.cpp.cpp",
92+
csh: "text.script.csh",
93+
css: "text.css",
94+
ctrl: "sourcecode.glsl",
95+
cxx: "sourcecode.cpp.cpp",
96+
d: "sourcecode.dtrace",
97+
dSYM: "wrapper.dsym",
98+
dae: "text.xml.dae",
99+
defs: "sourcecode.mig",
100+
dext: "wrapper.driver-extension",
101+
dict: "text.plist",
102+
docc: "folder.documentationcatalog",
103+
dsym: "wrapper.dsym",
104+
dtd: "text.xml",
105+
dylan: "sourcecode.dylan",
47106
dylib: "compiled.mach-o.dylib",
107+
ear: "archive.ear",
48108
entitlements: "text.plist.entitlements",
109+
eval: "sourcecode.glsl",
110+
exp: "sourcecode.exports",
111+
f: "sourcecode.fortran",
112+
f77: "sourcecode.fortran.f77",
113+
f90: "sourcecode.fortran.f90",
114+
f95: "sourcecode.fortran.f90",
115+
for: "sourcecode.fortran",
116+
frag: "sourcecode.glsl",
117+
fragment: "sourcecode.glsl",
49118
framework: "wrapper.framework",
119+
fs: "sourcecode.glsl",
120+
fsh: "sourcecode.glsl",
121+
geom: "sourcecode.glsl",
122+
geometry: "sourcecode.glsl",
50123
gif: "image.gif",
124+
gmk: "sourcecode.make",
51125
gpx: "text.xml",
126+
gs: "sourcecode.glsl",
127+
gsh: "sourcecode.glsl",
128+
gz: "archive.gzip",
52129
h: "sourcecode.c.h",
130+
"h++": "sourcecode.cpp.h",
131+
hh: "sourcecode.cpp.h",
132+
hp: "sourcecode.cpp.h",
53133
hpp: "sourcecode.cpp.h",
134+
hqx: "archive.binhex",
135+
htm: "text.html",
136+
html: "text.html",
137+
htmld: "wrapper.htmld",
138+
hxx: "sourcecode.cpp.h",
139+
i: "sourcecode.c.c.preprocessed",
140+
icns: "image.icns",
141+
ico: "image.ico",
142+
iconset: "folder.iconset",
143+
ii: "sourcecode.cpp.cpp.preprocessed",
144+
iig: "sourcecode.iig",
145+
imagecatalog: "folder.imagecatalog",
146+
inc: "sourcecode.pascal",
147+
instrdst: "com.apple.instruments.instrdst",
148+
instrpkg: "com.apple.instruments.package-definition",
149+
intentdefinition: "file.intentdefinition",
150+
ipp: "sourcecode.cpp.h",
151+
jam: "sourcecode.jam",
152+
jar: "archive.jar",
153+
java: "sourcecode.java",
154+
javascript: "sourcecode.javascript",
155+
jpeg: "image.jpeg",
156+
jpg: "image.jpeg",
157+
js: "sourcecode.javascript",
158+
jscript: "sourcecode.javascript",
159+
json: "text.json",
160+
jsp: "text.html.other",
161+
kext: "wrapper.kernel-extension",
162+
l: "sourcecode.lex",
163+
lid: "sourcecode.dylan",
164+
ll: "sourcecode.asm.llvm",
165+
llx: "sourcecode.asm.llvm",
166+
lm: "sourcecode.lex",
167+
lmm: "sourcecode.lex",
168+
lp: "sourcecode.lex",
169+
lpp: "sourcecode.lex",
170+
lxx: "sourcecode.lex",
54171
m: "sourcecode.c.objc",
55-
markdown: "text",
56-
mdimporter: "wrapper.cfbundle",
57-
modulemap: "sourcecode.module",
172+
mak: "sourcecode.make",
173+
make: "sourcecode.make",
174+
map: "sourcecode.module-map",
175+
markdown: "net.daringfireball.markdown",
176+
md: "net.daringfireball.markdown",
177+
mdimporter: "wrapper.spotlight-importer",
178+
mdown: "net.daringfireball.markdown",
179+
metal: "sourcecode.metal",
180+
metallib: "archive.metal-library",
181+
mi: "sourcecode.c.objc.preprocessed",
182+
mid: "audio.midi",
183+
midi: "audio.midi",
184+
mig: "sourcecode.mig",
185+
mii: "sourcecode.cpp.objcpp.preprocessed",
186+
mlkitmodel: "file.mlmodel",
187+
mlmodel: "file.mlmodel",
188+
mm: "sourcecode.cpp.objcpp",
189+
modulemap: "sourcecode.module-map",
190+
moov: "video.quicktime",
58191
mov: "video.quicktime",
59192
mp3: "audio.mp3",
193+
mpeg: "video.mpeg",
194+
mpg: "video.mpeg",
195+
mpkg: "wrapper.installer-mpkg",
196+
nasm: "sourcecode.nasm",
197+
nib: "wrapper.nib",
198+
"nib~": "wrapper.nib",
199+
nqc: "sourcecode.nqc",
200+
o: "compiled.mach-o.objfile",
60201
octest: "wrapper.cfbundle",
202+
otf: "file",
203+
p: "sourcecode.pascal",
204+
pas: "sourcecode.pascal",
205+
pbfilespec: "text.plist.pbfilespec",
206+
pblangspec: "text.plist.pblangspec",
207+
pbxproj: "text.pbxproject",
61208
pch: "sourcecode.c.h",
62-
plist: "text.plist.xml",
209+
"pch++": "sourcecode.cpp.h",
210+
pct: "image.pict",
211+
pdf: "image.pdf",
212+
perl: "text.script.perl",
213+
php: "text.script.php",
214+
php3: "text.script.php",
215+
php4: "text.script.php",
216+
phtml: "text.script.php",
217+
pict: "image.pict",
218+
pkg: "wrapper.installer-pkg",
219+
pl: "text.script.perl",
220+
playground: "file.playground",
221+
plist: "text.plist",
222+
pluginkit: "wrapper.app-extension",
223+
pm: "text.script.perl",
63224
png: "image.png",
225+
pp: "sourcecode.pascal",
226+
ppob: "archive.ppob",
227+
proto: "sourcecode.protobuf",
228+
py: "text.script.python",
229+
qtz: "video.quartz-composer",
230+
r: "sourcecode.rez",
231+
rb: "text.script.ruby",
232+
rbw: "text.script.ruby",
233+
rcproject: "file.rcproject",
234+
rcx: "compiled.rcx",
235+
rez: "sourcecode.rez",
236+
rhtml: "text.html.other",
237+
rsrc: "archive.rsrc",
238+
rtf: "text.rtf",
239+
rtfd: "wrapper.rtfd",
240+
s: "sourcecode.asm",
241+
scnassets: "wrapper.scnassets",
242+
scncache: "wrapper.scncache",
243+
scnp: "file.scp",
244+
scriptSuite: "text.plist.scriptSuite",
245+
scriptTerminology: "text.plist.scriptTerminology",
64246
sh: "text.script.sh",
247+
shtml: "text.html.other",
248+
sit: "archive.stuffit",
65249
sks: "file.sks",
250+
skybox: "file.skybox",
251+
sqlite: "file",
66252
storyboard: "file.storyboard",
253+
storyboardc: "wrapper.storyboardc",
67254
strings: "text.plist.strings",
255+
stringsdict: "text.plist.stringsdict",
68256
swift: "sourcecode.swift",
257+
systemextension: "wrapper.system-extension",
258+
tar: "archive.tar",
259+
tbd: "sourcecode.text-based-dylib-definition",
260+
tcc: "sourcecode.cpp.cpp",
261+
text: "net.daringfireball.markdown",
262+
tif: "image.tiff",
263+
tiff: "image.tiff",
264+
ttf: "file",
265+
txt: "text",
266+
uicatalog: "file.uicatalog",
267+
usdz: "file.usdz",
268+
vert: "sourcecode.glsl",
269+
vertex: "sourcecode.glsl",
270+
view: "archive.rsrc",
271+
vs: "sourcecode.glsl",
272+
vsh: "sourcecode.glsl",
273+
war: "archive.war",
274+
wav: "audio.wav",
275+
worksheet: "text.script.worksheet",
69276
xcassets: "folder.assetcatalog",
277+
xcbuildrules: "text.plist.xcbuildrules",
278+
xcclassmodel: "wrapper.xcclassmodel",
70279
xcconfig: "text.xcconfig",
71280
xcdatamodel: "wrapper.xcdatamodel",
281+
xcdatamodeld: "wrapper.xcdatamodeld",
282+
xcfilelist: "text.xcfilelist",
283+
xcframework: "wrapper.xcframework",
284+
xclangspec: "text.plist.xclangspec",
285+
xcmappingmodel: "wrapper.xcmappingmodel",
286+
xcode: "wrapper.pb-project",
72287
xcodeproj: "wrapper.pb-project",
288+
xconf: "text.xml",
289+
xcplaygroundpage: "file.xcplaygroundpage",
290+
xcspec: "text.plist.xcspec",
291+
xcstickers: "folder.stickers",
292+
xcsynspec: "text.plist.xcsynspec",
293+
xctarget: "wrapper.pb-target",
73294
xctest: "wrapper.cfbundle",
295+
xctxtmacro: "text.plist.xctxtmacro",
296+
xcworkspace: "wrapper.workspace",
297+
xhtml: "text.xml",
74298
xib: "file.xib",
299+
xmap: "text.xml",
300+
xml: "text.xml",
301+
xpc: "wrapper.xpc-service",
302+
xsl: "text.xml",
303+
xslt: "text.xml",
304+
xsp: "text.xml",
305+
y: "sourcecode.yacc",
306+
yaml: "text.yaml",
307+
ym: "sourcecode.yacc",
308+
yml: "text.yaml",
309+
ymm: "sourcecode.yacc",
310+
yp: "sourcecode.yacc",
311+
ypp: "sourcecode.yacc",
312+
yxx: "sourcecode.yacc",
75313
zip: "archive.zip",
76-
intentdefinition: "file.intentdefinition",
77-
js: "sourcecode.javascript",
78-
json: "text.json",
79-
html: "text.html",
80-
css: "text.css",
81314
});
82315

83316
export const PRODUCT_UTI_EXTENSIONS = Object.freeze({

0 commit comments

Comments
 (0)