Skip to content

Commit 5aaca2b

Browse files
committed
fix: Add C++ Source files to the Sources group
They were wrongly being added to Resources.
1 parent f6acdd4 commit 5aaca2b

File tree

2 files changed

+66
-54
lines changed

2 files changed

+66
-54
lines changed

lib/pbxFile.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var $path = require('path'),
22
util = require('util'),
3+
HEADER_FILE_TYPE_SUFFIX = ".h",
4+
SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode.",
35
M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
46
C_EXTENSION = /[.]c$/, C_SOURCE_FILE = 'sourcecode.c',
57
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
@@ -32,6 +34,14 @@ function fileTypes() {
3234
}
3335
}
3436

37+
function isSourceOrHeaderFileType(fileType) {
38+
return fileType.startsWith(SOURCE_CODE_FILE_TYPE_PREFIX);
39+
}
40+
41+
function isHeaderFileType(fileType) {
42+
return fileType.endsWith(HEADER_FILE_TYPE_SUFFIX);
43+
}
44+
3545
function detectLastType(path) {
3646
if (M_EXTENSION.test(path))
3747
return SOURCE_FILE;
@@ -65,10 +75,10 @@ function detectLastType(path) {
6575

6676
if (ARCHIVE_EXTENSION.test(path))
6777
return ARCHIVE;
68-
78+
6979
if (PNG_EXTENSION.test(path))
7080
return PNG_IMAGE;
71-
81+
7282
// dunno
7383
return 'unknown';
7484
}
@@ -98,7 +108,7 @@ function correctPath(file, filepath) {
98108
}
99109

100110
function correctGroup(file) {
101-
if (file.lastType == SOURCE_FILE) {
111+
if (isSourceOrHeaderFileType(file.lastType) && !isHeaderFileType(file.lastType)) {
102112
return 'Sources';
103113
} else if (file.lastType == DYLIB || file.lastType == ARCHIVE || file.lastType == FRAMEWORK) {
104114
return 'Frameworks';
@@ -137,5 +147,7 @@ function pbxFile(filepath, opt) {
137147

138148
module.exports = {
139149
pbxFile: pbxFile,
140-
fileTypes: fileTypes
150+
fileTypes: fileTypes,
151+
isSourceOrHeaderFileType,
152+
isHeaderFileType,
141153
}

0 commit comments

Comments
 (0)