@@ -927,11 +927,7 @@ pbxProject.prototype.addToLibrarySearchPaths = function (file) {
927
927
buildSettings [ 'LIBRARY_SEARCH_PATHS' ] = [ INHERITED ] ;
928
928
}
929
929
930
- if ( typeof file === 'string' ) {
931
- buildSettings [ 'LIBRARY_SEARCH_PATHS' ] . push ( file ) ;
932
- } else {
933
- buildSettings [ 'LIBRARY_SEARCH_PATHS' ] . push ( searchPathForFile ( file , this ) ) ;
934
- }
930
+ buildSettings [ 'LIBRARY_SEARCH_PATHS' ] . push ( searchPathForFile ( file , this ) ) ;
935
931
}
936
932
}
937
933
@@ -940,7 +936,7 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function (file) {
940
936
INHERITED = '"$(inherited)"' ,
941
937
SEARCH_PATHS = 'HEADER_SEARCH_PATHS' ,
942
938
config , buildSettings , searchPaths ;
943
- var new_path = typeof file === 'string' ? file : searchPathForFile ( file , this ) ;
939
+ var new_path = searchPathForFile ( file , this ) ;
944
940
945
941
for ( config in configurations ) {
946
942
buildSettings = configurations [ config ] . buildSettings ;
@@ -976,11 +972,7 @@ pbxProject.prototype.addToHeaderSearchPaths = function (file) {
976
972
buildSettings [ 'HEADER_SEARCH_PATHS' ] = [ INHERITED ] ;
977
973
}
978
974
979
- if ( typeof file === 'string' ) {
980
- buildSettings [ 'HEADER_SEARCH_PATHS' ] . push ( file ) ;
981
- } else {
982
- buildSettings [ 'HEADER_SEARCH_PATHS' ] . push ( searchPathForFile ( file , this ) ) ;
983
- }
975
+ buildSettings [ 'HEADER_SEARCH_PATHS' ] . push ( searchPathForFile ( file , this ) ) ;
984
976
}
985
977
}
986
978
@@ -1130,8 +1122,27 @@ function correctForPath(file, project, group) {
1130
1122
}
1131
1123
1132
1124
function searchPathForFile ( file , proj ) {
1125
+ const getPathString = ( filePath ) => {
1126
+ return `"\\"${ filePath } \\""` ;
1127
+ }
1128
+
1129
+ const getRelativePathString = ( filePath ) => {
1130
+ return getPathString ( `$(SRCROOT)/${ filePath } ` ) ;
1131
+ }
1132
+
1133
+ if ( typeof file === 'string' ) {
1134
+ const relativeFilePath = file ;
1135
+
1136
+ if ( $path . isAbsolute ( file ) ) {
1137
+ const srcRoot = $path . dirname ( $path . dirname ( proj . filepath ) ) ;
1138
+ relativeFilePath = $path . relative ( srcRoot , file ) ;
1139
+ }
1140
+
1141
+ return getRelativePathString ( relativeFilePath ) ;
1142
+ }
1143
+
1133
1144
if ( file . relativePath ) {
1134
- return '"\$(SRCROOT)/' + file . relativePath + '\"' ;
1145
+ return getRelativePathString ( file . relativePath ) ;
1135
1146
}
1136
1147
1137
1148
var plugins = proj . pbxGroupByName ( 'Plugins' ) ,
@@ -1145,11 +1156,11 @@ function searchPathForFile(file, proj) {
1145
1156
}
1146
1157
1147
1158
if ( file . plugin && pluginsPath ) {
1148
- return '"\\"$(SRCROOT)/' + unquote ( pluginsPath ) + '\\""' ;
1159
+ return getRelativePathString ( unquote ( pluginsPath ) ) ;
1149
1160
} else if ( file . customFramework && file . dirname ) {
1150
- return '"\\"' + file . dirname + '\\""' ;
1161
+ return getPathString ( file . dirname ) ;
1151
1162
} else {
1152
- return '"\\"$(SRCROOT)/' + proj . productName + fileDir + '\\""' ;
1163
+ return getRelativePathString ( proj . productName + fileDir ) ;
1153
1164
}
1154
1165
}
1155
1166
0 commit comments