@@ -181,9 +181,8 @@ pbxProject.prototype.removeResourceFile = function (path, opt) {
181181 return file ;
182182}
183183
184- pbxProject . prototype . addFramework = function ( path , opt ) {
185- var file = new pbxFile ( path , opt ) ;
186-
184+ pbxProject . prototype . addFramework = function ( fpath , opt ) {
185+ var file = new pbxFile ( fpath , opt ) ;
187186 // catch duplicates
188187 if ( this . hasFile ( file . path ) ) return false ;
189188
@@ -194,17 +193,25 @@ pbxProject.prototype.addFramework = function (path, opt) {
194193 this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
195194 this . addToFrameworksPbxGroup ( file ) ; // PBXGroup
196195 this . addToPbxFrameworksBuildPhase ( file ) ; // PBXFrameworksBuildPhase
196+
197+ if ( opt && opt . customFramework == true ) {
198+ this . addToFrameworkSearchPaths ( file ) ;
199+ }
197200
198201 return file ;
199202}
200203
201- pbxProject . prototype . removeFramework = function ( path , opt ) {
202- var file = new pbxFile ( path , opt ) ;
204+ pbxProject . prototype . removeFramework = function ( fpath , opt ) {
205+ var file = new pbxFile ( fpath , opt ) ;
203206
204207 this . removeFromPbxBuildFileSection ( file ) ; // PBXBuildFile
205208 this . removeFromPbxFileReferenceSection ( file ) ; // PBXFileReference
206209 this . removeFromFrameworksPbxGroup ( file ) ; // PBXGroup
207210 this . removeFromPbxFrameworksBuildPhase ( file ) ; // PBXFrameworksBuildPhase
211+
212+ if ( opt && opt . customFramework ) {
213+ this . removeFromFrameworkSearchPaths ( path . dirname ( fpath ) ) ;
214+ }
208215
209216 return file ;
210217}
@@ -443,6 +450,54 @@ pbxProject.prototype.updateProductName = function(name) {
443450 propReplace ( config , 'PRODUCT_NAME' , '"' + name + '"' ) ;
444451}
445452
453+ pbxProject . prototype . removeFromFrameworkSearchPaths = function ( file ) {
454+ var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
455+ INHERITED = '"$(inherited)"' ,
456+ SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS' ,
457+ config , buildSettings , searchPaths ;
458+ var new_path = searchPathForFile ( file , this ) ;
459+
460+ for ( config in configurations ) {
461+ buildSettings = configurations [ config ] . buildSettings ;
462+
463+ if ( unquote ( buildSettings [ 'PRODUCT_NAME' ] ) != this . productName )
464+ continue ;
465+
466+ searchPaths = buildSettings [ SEARCH_PATHS ] ;
467+
468+ if ( searchPaths ) {
469+ var matches = searchPaths . filter ( function ( p ) {
470+ return p . indexOf ( new_path ) > - 1 ;
471+ } ) ;
472+ matches . forEach ( function ( m ) {
473+ var idx = searchPaths . indexOf ( m ) ;
474+ searchPaths . splice ( idx , 1 ) ;
475+ } ) ;
476+ }
477+
478+ }
479+ }
480+
481+ pbxProject . prototype . addToFrameworkSearchPaths = function ( file ) {
482+ var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
483+ INHERITED = '"$(inherited)"' ,
484+ config , buildSettings , searchPaths ;
485+
486+ for ( config in configurations ) {
487+ buildSettings = configurations [ config ] . buildSettings ;
488+
489+ if ( unquote ( buildSettings [ 'PRODUCT_NAME' ] ) != this . productName )
490+ continue ;
491+
492+ if ( ! buildSettings [ 'FRAMEWORK_SEARCH_PATHS' ]
493+ || buildSettings [ 'FRAMEWORK_SEARCH_PATHS' ] === INHERITED ) {
494+ buildSettings [ 'FRAMEWORK_SEARCH_PATHS' ] = [ INHERITED ] ;
495+ }
496+
497+ buildSettings [ 'FRAMEWORK_SEARCH_PATHS' ] . push ( searchPathForFile ( file , this ) ) ;
498+ }
499+ }
500+
446501pbxProject . prototype . removeFromLibrarySearchPaths = function ( file ) {
447502 var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
448503 INHERITED = '"$(inherited)"' ,
@@ -552,10 +607,8 @@ pbxProject.prototype.__defineGetter__("productName", function () {
552607pbxProject . prototype . hasFile = function ( filePath ) {
553608 var files = nonComments ( this . pbxFileReferenceSection ( ) ) ,
554609 file , id ;
555-
556610 for ( id in files ) {
557611 file = files [ id ] ;
558-
559612 if ( file . path == filePath || file . path == ( '"' + filePath + '"' ) ) {
560613 return true ;
561614 }
@@ -655,6 +708,15 @@ function correctForResourcesPath(file, project) {
655708 return file ;
656709}
657710
711+ function correctForFrameworksPath ( file , project ) {
712+ var r_resources_dir = / ^ F r a m e w o r k s \/ / ;
713+
714+ if ( project . pbxGroupByName ( 'Frameworks' ) . path )
715+ file . path = file . path . replace ( r_resources_dir , '' ) ;
716+
717+ return file ;
718+ }
719+
658720function searchPathForFile ( file , proj ) {
659721 var plugins = proj . pbxGroupByName ( 'Plugins' )
660722 pluginsPath = plugins ? plugins . path : null ,
@@ -668,6 +730,8 @@ function searchPathForFile(file, proj) {
668730
669731 if ( file . plugin && pluginsPath ) {
670732 return '"\\"$(SRCROOT)/' + unquote ( pluginsPath ) + '\\""' ;
733+ } else if ( file . customFramework && file . dirname ) {
734+ return '"' + file . dirname + '"'
671735 } else {
672736 return '"\\"$(SRCROOT)/' + proj . productName + fileDir + '\\""' ;
673737 }
0 commit comments