@@ -927,11 +927,7 @@ pbxProject.prototype.addToLibrarySearchPaths = function (file) {
927927 buildSettings [ 'LIBRARY_SEARCH_PATHS' ] = [ INHERITED ] ;
928928 }
929929
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 ) ) ;
935931 }
936932}
937933
@@ -940,7 +936,7 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function (file) {
940936 INHERITED = '"$(inherited)"' ,
941937 SEARCH_PATHS = 'HEADER_SEARCH_PATHS' ,
942938 config , buildSettings , searchPaths ;
943- var new_path = typeof file === 'string' ? file : searchPathForFile ( file , this ) ;
939+ var new_path = searchPathForFile ( file , this ) ;
944940
945941 for ( config in configurations ) {
946942 buildSettings = configurations [ config ] . buildSettings ;
@@ -976,11 +972,7 @@ pbxProject.prototype.addToHeaderSearchPaths = function (file) {
976972 buildSettings [ 'HEADER_SEARCH_PATHS' ] = [ INHERITED ] ;
977973 }
978974
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 ) ) ;
984976 }
985977}
986978
@@ -1130,8 +1122,27 @@ function correctForPath(file, project, group) {
11301122}
11311123
11321124function 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+
11331144 if ( file . relativePath ) {
1134- return '"\$(SRCROOT)/' + file . relativePath + '\"' ;
1145+ return getRelativePathString ( file . relativePath ) ;
11351146 }
11361147
11371148 var plugins = proj . pbxGroupByName ( 'Plugins' ) ,
@@ -1145,11 +1156,11 @@ function searchPathForFile(file, proj) {
11451156 }
11461157
11471158 if ( file . plugin && pluginsPath ) {
1148- return '"\\"$(SRCROOT)/' + unquote ( pluginsPath ) + '\\""' ;
1159+ return getRelativePathString ( unquote ( pluginsPath ) ) ;
11491160 } else if ( file . customFramework && file . dirname ) {
1150- return '"\\"' + file . dirname + '\\""' ;
1161+ return getPathString ( file . dirname ) ;
11511162 } else {
1152- return '"\\"$(SRCROOT)/' + proj . productName + fileDir + '\\""' ;
1163+ return getRelativePathString ( proj . productName + fileDir ) ;
11531164 }
11541165}
11551166
0 commit comments