Skip to content

Commit 32f65ec

Browse files
committed
[pbxFile] support .framework (not just dylib)
1 parent d3f4301 commit 32f65ec

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

lib/pbxFile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ var path = require('path'),
33
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
44
BUNDLE_EXTENSION = /[.]bundle$/, BUNDLE = '"wrapper.plug-in"',
55
XIB_EXTENSION = /[.]xib$/, XIB_FILE = 'file.xib',
6-
FRAMEWORK_EXTENSION = /[.]dylib$/, FRAMEWORK = '"compiled.mach-o.dylib"',
6+
DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
7+
FRAMEWORK_EXTENSION = /[.]framework/, FRAMEWORK = 'wrapper.framework',
78
DEFAULT_SOURCE_TREE = '"<group>"',
89
DEFAULT_FILE_ENCODING = 4;
910

@@ -23,6 +24,9 @@ function detectLastType(path) {
2324
if (FRAMEWORK_EXTENSION.test(path))
2425
return FRAMEWORK;
2526

27+
if (DYLIB_EXTENSION.test(path))
28+
return DYLIB;
29+
2630
// dunno
2731
return 'unknown';
2832
}
@@ -34,7 +38,7 @@ function fileEncoding(file) {
3438
}
3539

3640
function defaultSourceTree(file) {
37-
if (file.lastType == FRAMEWORK) {
41+
if (file.lastType == DYLIB || file.lastType == FRAMEWORK) {
3842
return 'SDKROOT';
3943
} else {
4044
return DEFAULT_SOURCE_TREE;
@@ -43,6 +47,8 @@ function defaultSourceTree(file) {
4347

4448
function correctPath(file, filepath) {
4549
if (file.lastType == FRAMEWORK) {
50+
return 'System/Library/Frameworks/' + filepath;
51+
} else if (file.lastType == DYLIB) {
4652
return 'usr/lib/' + filepath;
4753
} else {
4854
return filepath;
@@ -52,7 +58,7 @@ function correctPath(file, filepath) {
5258
function correctGroup(file) {
5359
if (file.lastType == SOURCE_FILE) {
5460
return 'Sources';
55-
} else if (file.lastType == FRAMEWORK) {
61+
} else if (file.lastType == DYLIB) {
5662
return 'Frameworks';
5763
} else {
5864
return 'Resources';

test/pbxFile.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ exports['lastType'] = {
3636
test.done();
3737
},
3838

39+
'should detect that a .framework path means wrapper.framework': function (test) {
40+
var sourceFile = new pbxFile('MessageUI.framework');
41+
42+
test.equal('wrapper.framework', sourceFile.lastType);
43+
test.done();
44+
},
45+
3946
'should allow lastType to be overridden': function (test) {
4047
var sourceFile = new pbxFile('Plugins/ChildBrowser.m',
4148
{ lastType: 'somestupidtype' });
@@ -85,13 +92,20 @@ exports['basename'] = {
8592
}
8693

8794
exports['sourceTree'] = {
88-
'should be SDKROOT for frameworks': function (test) {
95+
'should be SDKROOT for dylibs': function (test) {
8996
var sourceFile = new pbxFile('libsqlite3.dylib');
9097

9198
test.equal('SDKROOT', sourceFile.sourceTree);
9299
test.done();
93100
},
94101

102+
'should be SDKROOT for frameworks': function (test) {
103+
var sourceFile = new pbxFile('MessageUI.framework');
104+
105+
test.equal('SDKROOT', sourceFile.sourceTree);
106+
test.done();
107+
},
108+
95109
'should default to "<group>" otherwise': function (test) {
96110
var sourceFile = new pbxFile('Plugins/ChildBrowser.m');
97111

@@ -109,13 +123,21 @@ exports['sourceTree'] = {
109123
}
110124

111125
exports['path'] = {
112-
'should be "usr/lib" for frameworks (relative to SDKROOT)': function (test) {
126+
'should be "usr/lib" for dylibs (relative to SDKROOT)': function (test) {
113127
var sourceFile = new pbxFile('libsqlite3.dylib');
114128

115129
test.equal('usr/lib/libsqlite3.dylib', sourceFile.path);
116130
test.done();
117131
},
118132

133+
'should be "System/Library/Frameworks" for frameworks': function (test) {
134+
var sourceFile = new pbxFile('MessageUI.framework');
135+
136+
test.equal('System/Library/Frameworks/MessageUI.framework', sourceFile.path);
137+
test.done();
138+
},
139+
140+
119141
'should default to the first argument otherwise': function (test) {
120142
var sourceFile = new pbxFile('Plugins/ChildBrowser.m');
121143

0 commit comments

Comments
 (0)