diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 59dcef9..2ed90be 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -34,6 +34,7 @@ const FILETYPE_BY_EXTENSION = { framework: 'wrapper.framework', h: 'sourcecode.c.h', m: 'sourcecode.c.objc', + mm: 'sourcecode.cpp.objcpp', markdown: 'text', mdimporter: 'wrapper.cfbundle', octest: 'wrapper.cfbundle', @@ -58,6 +59,7 @@ const GROUP_BY_FILETYPE = { 'embedded.framework': 'Embed Frameworks', 'sourcecode.c.h': 'Resources', 'sourcecode.c.objc': 'Sources', + 'sourcecode.cpp.objcpp': 'Sources', 'sourcecode.swift': 'Sources' }; const PATH_BY_FILETYPE = { @@ -73,6 +75,7 @@ const SOURCETREE_BY_FILETYPE = { const ENCODING_BY_FILETYPE = { 'sourcecode.c.h': 4, 'sourcecode.c.objc': 4, + 'sourcecode.cpp.objcpp': 4, 'sourcecode.swift': 4, text: 4, 'text.plist.xml': 4, diff --git a/test/addSourceFile.js b/test/addSourceFile.js index 409bad0..053fae7 100644 --- a/test/addSourceFile.js +++ b/test/addSourceFile.js @@ -162,4 +162,31 @@ describe('addSourceFile', () => { assert.strictEqual(plugins.children.length, 1); assert.strictEqual(sources.files.length, 3); }); + + it('should add objc source files and return pbxFile', () => { + const newFile = proj.addSourceFile('file.m'); + assert.strictEqual(newFile.constructor, PBXFile); + assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.c.objc'); + assert.strictEqual(newFile.group, 'Sources'); + assert.strictEqual(newFile.defaultEncoding, 4); + assert.strictEqual(newFile.fileEncoding, 4); + }); + + it('should add objc++ source files and return pbxFile', () => { + const newFile = proj.addSourceFile('file.mm'); + assert.strictEqual(newFile.constructor, PBXFile); + assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.cpp.objcpp'); + assert.strictEqual(newFile.group, 'Sources'); + assert.strictEqual(newFile.defaultEncoding, 4); + assert.strictEqual(newFile.fileEncoding, 4); + }); + + it('should add swift source files and return pbxFile', () => { + const newFile = proj.addSourceFile('file.swift'); + assert.strictEqual(newFile.constructor, PBXFile); + assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.swift'); + assert.strictEqual(newFile.group, 'Sources'); + assert.strictEqual(newFile.defaultEncoding, 4); + assert.strictEqual(newFile.fileEncoding, 4); + }); });