pbxFile: Replace string-based internal filetype dictionaries with object-based maps, using currently known values (XCode 7.0)
diff --git a/lib/pbxFile.js b/lib/pbxFile.js
index 5baa823..95d770f 100644
--- a/lib/pbxFile.js
+++ b/lib/pbxFile.js
@@ -1,14 +1,74 @@
var path = require('path'),
- util = require('util'),
- M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
- H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
- BUNDLE_EXTENSION = /[.]bundle$/, BUNDLE = '"wrapper.plug-in"',
- XIB_EXTENSION = /[.]xib$/, XIB_FILE = 'file.xib',
- DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
- FRAMEWORK_EXTENSION = /[.]framework/, FRAMEWORK = 'wrapper.framework',
- ARCHIVE_EXTENSION = /[.]a$/, ARCHIVE = 'archive.ar',
- DEFAULT_SOURCE_TREE = '"<group>"',
- DEFAULT_FILE_ENCODING = 4;
+ util = require('util');
+
+var DEFAULT_SOURCETREE = '"<group>"',
+ DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR',
+ DEFAULT_FILEENCODING = 4,
+ DEFAULT_GROUP = 'Resources',
+ DEFAULT_FILETYPE = 'unknown';
+
+var FILETYPE_BY_EXTENSION = {
+ a: 'archive.ar',
+ app: 'wrapper.application',
+ appex: 'wrapper.app-extension',
+ bundle: 'wrapper.plug-in',
+ dylib: 'compiled.mach-o.dylib',
+ framework: 'wrapper.framework',
+ h: 'sourcecode.c.h',
+ m: 'sourcecode.c.objc',
+ markdown: 'text',
+ mdimporter: 'wrapper.cfbundle',
+ octest: 'wrapper.cfbundle',
+ pch: 'sourcecode.c.h',
+ plist: 'text.plist.xml',
+ sh: 'text.script.sh',
+ swift: 'sourcecode.swift',
+ xcassets: 'folder.assetcatalog',
+ xcconfig: 'text.xcconfig',
+ xcdatamodel: 'wrapper.xcdatamodel',
+ xcodeproj: 'wrapper.pb-project',
+ xctest: 'wrapper.cfbundle',
+ xib: 'file.xib'
+ },
+ EXTENSION_BY_PRODUCTTYPE = {
+ 'com.apple.product-type.application': 'app',
+ 'com.apple.product-type.application.watchapp': 'app',
+ 'com.apple.product-type.app-extension': 'appex',
+ 'com.apple.product-type.watchkit-extension': 'appex',
+ 'com.apple.product-type.bundle': 'bundle',
+ 'com.apple.product-type.bundle.unit-test': 'xctest',
+ 'com.apple.product-type.framework': 'framework',
+ 'com.apple.product-type.library.dynamic': 'dylib',
+ 'com.apple.product-type.library.static': 'a',
+ 'com.apple.product-type.tool': ''
+ },
+ GROUP_BY_FILETYPE = {
+ 'archive.ar': 'Frameworks',
+ 'compiled.mach-o.dylib': 'Frameworks',
+ 'wrapper.framework': 'Frameworks',
+ 'sourcecode.c.h': 'Sources',
+ 'sourcecode.c.objc': 'Sources',
+ 'sourcecode.swift': 'Sources'
+ },
+ PATH_BY_FILETYPE = {
+ 'compiled.mach-o.dylib': 'usr/lib/',
+ 'wrapper.framework': 'System/Library/Frameworks/'
+ },
+ SOURCETREE_BY_FILETYPE = {
+ 'compiled.mach-o.dylib': 'SDKROOT',
+ 'wrapper.framework': 'SDKROOT'
+ },
+ ENCODING_BY_FILETYPE = {
+ 'sourcecode.c.h': 4,
+ 'sourcecode.c.h': 4,
+ 'sourcecode.c.objc': 4,
+ 'sourcecode.swift': 4,
+ 'text': 4,
+ 'text.plist.xml': 4,
+ 'text.script.sh': 4,
+ 'text.xcconfig': 4
+ };
+
function detectLastType(path) {
if (M_EXTENSION.test(path))