Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/pbxFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ const FILETYPE_BY_EXTENSION = {
app: 'wrapper.application',
appex: 'wrapper.app-extension',
bundle: 'wrapper.plug-in',
c: 'sourcecode.c.c',
cpp: 'sourcecode.cpp.cpp',
cc: 'sourcecode.cpp.cpp',
cxx: 'sourcecode.cpp.cpp',
dylib: 'compiled.mach-o.dylib',
framework: 'wrapper.framework',
h: 'sourcecode.c.h',
hpp: 'sourcecode.cpp.h',
m: 'sourcecode.c.objc',
mm: 'sourcecode.cpp.objcpp',
markdown: 'text',
Expand All @@ -57,8 +62,11 @@ const GROUP_BY_FILETYPE = {
'sourcecode.text-based-dylib-definition': 'Frameworks',
'wrapper.framework': 'Frameworks',
'embedded.framework': 'Embed Frameworks',
'sourcecode.c.c': 'Sources',
'sourcecode.c.h': 'Resources',
'sourcecode.c.objc': 'Sources',
'sourcecode.cpp.cpp': 'Sources',
'sourcecode.cpp.h': 'Resources',
'sourcecode.cpp.objcpp': 'Sources',
'sourcecode.swift': 'Sources'
};
Expand All @@ -73,8 +81,11 @@ const SOURCETREE_BY_FILETYPE = {
'wrapper.framework': 'SDKROOT'
};
const ENCODING_BY_FILETYPE = {
'sourcecode.c.c': 4,
'sourcecode.c.h': 4,
'sourcecode.c.objc': 4,
'sourcecode.cpp.cpp': 4,
'sourcecode.cpp.h': 4,
'sourcecode.cpp.objcpp': 4,
'sourcecode.swift': 4,
text: 4,
Expand Down
9 changes: 9 additions & 0 deletions test/addHeaderFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,13 @@ describe('addHeaderFile', () => {
assert.equal(68, frsLength);
assert.equal(plugins.children.length, 1);
});

it('should add hpp header files and return pbxFile', () => {
const newFile = proj.addHeaderFile('file.hpp');
assert.strictEqual(newFile.constructor, PBXFile);
assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.cpp.h');
assert.strictEqual(newFile.group, 'Resources');
assert.strictEqual(newFile.defaultEncoding, 4);
assert.strictEqual(newFile.fileEncoding, 4);
});
});
36 changes: 36 additions & 0 deletions test/addSourceFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,40 @@ describe('addSourceFile', () => {
assert.strictEqual(newFile.defaultEncoding, 4);
assert.strictEqual(newFile.fileEncoding, 4);
});

it('should add c source files and return pbxFile', () => {
const newFile = proj.addSourceFile('file.c');
assert.strictEqual(newFile.constructor, PBXFile);
assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.c.c');
assert.strictEqual(newFile.group, 'Sources');
assert.strictEqual(newFile.defaultEncoding, 4);
assert.strictEqual(newFile.fileEncoding, 4);
});

it('should add cc source files and return pbxFile', () => {
const newFile = proj.addSourceFile('file.cc');
assert.strictEqual(newFile.constructor, PBXFile);
assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.cpp.cpp');
assert.strictEqual(newFile.group, 'Sources');
assert.strictEqual(newFile.defaultEncoding, 4);
assert.strictEqual(newFile.fileEncoding, 4);
});

it('should add cpp source files and return pbxFile', () => {
const newFile = proj.addSourceFile('file.cpp');
assert.strictEqual(newFile.constructor, PBXFile);
assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.cpp.cpp');
assert.strictEqual(newFile.group, 'Sources');
assert.strictEqual(newFile.defaultEncoding, 4);
assert.strictEqual(newFile.fileEncoding, 4);
});

it('should add cxx source files and return pbxFile', () => {
const newFile = proj.addSourceFile('file.cxx');
assert.strictEqual(newFile.constructor, PBXFile);
assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.cpp.cpp');
assert.strictEqual(newFile.group, 'Sources');
assert.strictEqual(newFile.defaultEncoding, 4);
assert.strictEqual(newFile.fileEncoding, 4);
});
});
Loading