Skip to content

Commit fc56521

Browse files
committed
pbxFile: Replace string-based internal filetype dictionaries with object-based maps, using currently known values (XCode 7.0)
1 parent af2a0e5 commit fc56521

File tree

1 file changed

+70
-10
lines changed

1 file changed

+70
-10
lines changed

lib/pbxFile.js

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,74 @@
11
var path = require('path'),
2-
util = require('util'),
3-
M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
4-
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
5-
BUNDLE_EXTENSION = /[.]bundle$/, BUNDLE = '"wrapper.plug-in"',
6-
XIB_EXTENSION = /[.]xib$/, XIB_FILE = 'file.xib',
7-
DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
8-
FRAMEWORK_EXTENSION = /[.]framework/, FRAMEWORK = 'wrapper.framework',
9-
ARCHIVE_EXTENSION = /[.]a$/, ARCHIVE = 'archive.ar',
10-
DEFAULT_SOURCE_TREE = '"<group>"',
11-
DEFAULT_FILE_ENCODING = 4;
2+
util = require('util');
3+
4+
var DEFAULT_SOURCETREE = '"<group>"',
5+
DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR',
6+
DEFAULT_FILEENCODING = 4,
7+
DEFAULT_GROUP = 'Resources',
8+
DEFAULT_FILETYPE = 'unknown';
9+
10+
var FILETYPE_BY_EXTENSION = {
11+
a: 'archive.ar',
12+
app: 'wrapper.application',
13+
appex: 'wrapper.app-extension',
14+
bundle: 'wrapper.plug-in',
15+
dylib: 'compiled.mach-o.dylib',
16+
framework: 'wrapper.framework',
17+
h: 'sourcecode.c.h',
18+
m: 'sourcecode.c.objc',
19+
markdown: 'text',
20+
mdimporter: 'wrapper.cfbundle',
21+
octest: 'wrapper.cfbundle',
22+
pch: 'sourcecode.c.h',
23+
plist: 'text.plist.xml',
24+
sh: 'text.script.sh',
25+
swift: 'sourcecode.swift',
26+
xcassets: 'folder.assetcatalog',
27+
xcconfig: 'text.xcconfig',
28+
xcdatamodel: 'wrapper.xcdatamodel',
29+
xcodeproj: 'wrapper.pb-project',
30+
xctest: 'wrapper.cfbundle',
31+
xib: 'file.xib'
32+
},
33+
EXTENSION_BY_PRODUCTTYPE = {
34+
'com.apple.product-type.application': 'app',
35+
'com.apple.product-type.application.watchapp': 'app',
36+
'com.apple.product-type.app-extension': 'appex',
37+
'com.apple.product-type.watchkit-extension': 'appex',
38+
'com.apple.product-type.bundle': 'bundle',
39+
'com.apple.product-type.bundle.unit-test': 'xctest',
40+
'com.apple.product-type.framework': 'framework',
41+
'com.apple.product-type.library.dynamic': 'dylib',
42+
'com.apple.product-type.library.static': 'a',
43+
'com.apple.product-type.tool': ''
44+
},
45+
GROUP_BY_FILETYPE = {
46+
'archive.ar': 'Frameworks',
47+
'compiled.mach-o.dylib': 'Frameworks',
48+
'wrapper.framework': 'Frameworks',
49+
'sourcecode.c.h': 'Sources',
50+
'sourcecode.c.objc': 'Sources',
51+
'sourcecode.swift': 'Sources'
52+
},
53+
PATH_BY_FILETYPE = {
54+
'compiled.mach-o.dylib': 'usr/lib/',
55+
'wrapper.framework': 'System/Library/Frameworks/'
56+
},
57+
SOURCETREE_BY_FILETYPE = {
58+
'compiled.mach-o.dylib': 'SDKROOT',
59+
'wrapper.framework': 'SDKROOT'
60+
},
61+
ENCODING_BY_FILETYPE = {
62+
'sourcecode.c.h': 4,
63+
'sourcecode.c.h': 4,
64+
'sourcecode.c.objc': 4,
65+
'sourcecode.swift': 4,
66+
'text': 4,
67+
'text.plist.xml': 4,
68+
'text.script.sh': 4,
69+
'text.xcconfig': 4
70+
};
71+
1272

1373
function detectLastType(path) {
1474
if (M_EXTENSION.test(path))

0 commit comments

Comments
 (0)