Skip to content

Commit 8427c53

Browse files
committed
[proj] static library plugins without group fix
1 parent 84d1841 commit 8427c53

File tree

2 files changed

+43
-16
lines changed

2 files changed

+43
-16
lines changed

lib/pbxProject.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,19 @@ function correctForResourcesPath(file, project) {
554554
}
555555

556556
function searchPathForFile(file, proj) {
557-
var pluginsPath = proj.pbxGroupByName('Plugins').path;
557+
var pluginsPath = proj.pbxGroupByName('Plugins').path,
558+
fileDir = path.dirname(file.path);
559+
560+
if (fileDir == '.') {
561+
fileDir = '';
562+
} else {
563+
fileDir = '/' + fileDir;
564+
}
558565

559566
if (file.plugin && pluginsPath) {
560567
return '"\\"$(SRCROOT)/' + unquote(pluginsPath) + '\\""';
561568
} else {
562-
return '"\\"$(SRCROOT)/' + proj.productName + '\\""';
569+
return '"\\"$(SRCROOT)/' + proj.productName + fileDir + '\\""';
563570
}
564571
}
565572

test/addStaticLibrary.js

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,42 @@ exports.addStaticLibrary = {
182182
test.equal(plugins.children.length, 1);
183183
test.done();
184184
},
185-
'should add the right LIBRARY_SEARCH_PATHS entry for plugins': function (test) {
186-
plugins = proj.pbxGroupByName('Plugins');
187-
plugins.path = '"Test200/Plugins"';
185+
'should add the right LIBRARY_SEARCH_PATHS entry for plugins': {
186+
'with group set': function (test) {
187+
plugins = proj.pbxGroupByName('Plugins');
188+
plugins.path = '"Test200/Plugins"';
189+
190+
var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a',
191+
{ plugin: true }),
192+
libraryPaths = librarySearchPaths(proj),
193+
expectedPath = '"\\"$(SRCROOT)/Test200/Plugins\\""',
194+
i, current;
195+
196+
for (i = 0; i < libraryPaths.length; i++) {
197+
current = libraryPaths[i];
198+
test.ok(current.indexOf(expectedPath) >= 0,
199+
expectedPath + ' not found in ' + current);
200+
}
188201

189-
var newFile = proj.addStaticLibrary('libGoogleAnalytics.a',
190-
{ plugin: true }),
191-
libraryPaths = librarySearchPaths(proj),
192-
expectedPath = '"\\"$(SRCROOT)/Test200/Plugins\\""',
193-
i, current;
202+
test.done();
203+
},
204+
'without group set': function (test) {
205+
plugins = proj.pbxGroupByName('Plugins');
206+
delete plugins.path;
207+
208+
var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a',
209+
{ plugin: true }),
210+
libraryPaths = librarySearchPaths(proj),
211+
expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet/Plugins\\""',
212+
i, current;
213+
214+
for (i = 0; i < libraryPaths.length; i++) {
215+
current = libraryPaths[i];
216+
test.ok(current.indexOf(expectedPath) >= 0,
217+
expectedPath + ' not found in ' + current);
218+
}
194219

195-
for (i = 0; i < libraryPaths.length; i++) {
196-
current = libraryPaths[i];
197-
test.ok(current.indexOf(expectedPath) >= 0,
198-
expectedPath + ' not found in ' + current);
220+
test.done();
199221
}
200-
201-
test.done();
202222
}
203223
}

0 commit comments

Comments
 (0)