Skip to content

Commit 71f488c

Browse files
FatmeKristian D. Dimitrov
authored andcommitted
Fix file references inside .pbxproject
1 parent 81e03fb commit 71f488c

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

lib/pbxProject.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,11 +1303,7 @@ pbxProject.prototype.addToLibrarySearchPaths = function(file) {
13031303
buildSettings['LIBRARY_SEARCH_PATHS'] = [INHERITED];
13041304
}
13051305

1306-
if (typeof file === 'string') {
1307-
buildSettings['LIBRARY_SEARCH_PATHS'].push(file);
1308-
} else {
1309-
buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this));
1310-
}
1306+
buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this));
13111307
}
13121308
}
13131309

@@ -1316,7 +1312,7 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function(file) {
13161312
INHERITED = '"$(inherited)"',
13171313
SEARCH_PATHS = 'HEADER_SEARCH_PATHS',
13181314
config, buildSettings, searchPaths;
1319-
var new_path = typeof file === 'string' ? file : searchPathForFile(file, this);
1315+
var new_path = searchPathForFile(file, this);
13201316

13211317
for (config in configurations) {
13221318
buildSettings = configurations[config].buildSettings;
@@ -1351,11 +1347,7 @@ pbxProject.prototype.addToHeaderSearchPaths = function(file) {
13511347
buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED];
13521348
}
13531349

1354-
if (typeof file === 'string') {
1355-
buildSettings['HEADER_SEARCH_PATHS'].push(file);
1356-
} else {
1357-
buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this));
1358-
}
1350+
buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this));
13591351
}
13601352
}
13611353

@@ -1720,8 +1712,27 @@ function correctForPath(file, project, group) {
17201712
}
17211713

17221714
function searchPathForFile(file, proj) {
1715+
const getPathString = (filePath) => {
1716+
return `"\\"${filePath}\\""`;
1717+
}
1718+
1719+
const getRelativePathString = (filePath) => {
1720+
return getPathString(`$(SRCROOT)/${filePath}`);
1721+
}
1722+
1723+
if (typeof file === 'string') {
1724+
const relativeFilePath = file;
1725+
1726+
if ($path.isAbsolute(file)) {
1727+
const srcRoot = $path.dirname($path.dirname(proj.filepath));
1728+
relativeFilePath = $path.relative(srcRoot, file);
1729+
}
1730+
1731+
return getRelativePathString(relativeFilePath);
1732+
}
1733+
17231734
if (file.relativePath) {
1724-
return '"\$(SRCROOT)/' + file.relativePath + '\"';
1735+
return getRelativePathString(file.relativePath);
17251736
}
17261737

17271738
var plugins = proj.pbxGroupByName('Plugins'),
@@ -1735,11 +1746,11 @@ function searchPathForFile(file, proj) {
17351746
}
17361747

17371748
if (file.plugin && pluginsPath) {
1738-
return '"\\"$(SRCROOT)/' + unquote(pluginsPath) + '\\""';
1749+
return getRelativePathString(unquote(pluginsPath));
17391750
} else if (file.customFramework && file.dirname) {
1740-
return '"\\"' + file.dirname + '\\""';
1751+
return getPathString(file.dirname);
17411752
} else {
1742-
return '"\\"$(SRCROOT)/' + proj.productName + fileDir + '\\""';
1753+
return getRelativePathString(proj.productName + fileDir);
17431754
}
17441755
}
17451756

0 commit comments

Comments
 (0)