@@ -261,6 +261,13 @@ pbxProject.prototype.removeResourceFile = function(path, opt) {
261261}
262262
263263pbxProject . prototype . addFramework = function ( fpath , opt ) {
264+ var customFramework = opt && opt . customFramework == true ;
265+ var link = ! opt || ( opt . link == undefined || opt . link ) ; //defaults to true if not specified
266+ var embed = opt && opt . embed ; //defaults to false if not specified
267+
268+ if ( opt ) {
269+ delete opt . embed ;
270+ }
264271
265272 var file = new pbxFile ( fpath , opt ) ;
266273
@@ -270,10 +277,6 @@ pbxProject.prototype.addFramework = function(fpath, opt) {
270277
271278 if ( this . hasFile ( file . path ) ) return false ;
272279
273- var customFramework = opt && opt . customFramework == true ;
274- var link = ! opt || ( opt . link == undefined || opt . link ) ; //defaults to true if not specified
275- var embed = opt && opt . embed ; //defaults to false if not specified
276-
277280 this . addToPbxBuildFileSection ( file ) ; // PBXBuildFile
278281 this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
279282 this . addToFrameworksPbxGroup ( file ) ; // PBXGroup
@@ -286,27 +289,52 @@ pbxProject.prototype.addFramework = function(fpath, opt) {
286289 this . addToFrameworkSearchPaths ( file ) ;
287290
288291 if ( embed ) {
289- this . addToPbxEmbedFrameworksBuildPhase ( file ) ; // PBXCopyFilesBuildPhase
292+ opt . embed = embed ;
293+ var embeddedFile = new pbxFile ( fpath , opt ) ;
294+
295+ embeddedFile . uuid = this . generateUuid ( ) ;
296+ embeddedFile . fileRef = file . fileRef ;
297+
298+ //keeping a separate PBXBuildFile entry for Embed Frameworks
299+ this . addToPbxBuildFileSection ( embeddedFile ) ; // PBXBuildFile
300+
301+ this . addToPbxEmbedFrameworksBuildPhase ( embeddedFile ) ; // PBXCopyFilesBuildPhase
302+
303+ return embeddedFile ;
290304 }
291305 }
292306
293307 return file ;
294308}
295309
296310pbxProject . prototype . removeFramework = function ( fpath , opt ) {
311+ var embed = opt && opt . embed ;
312+
313+ if ( opt ) {
314+ delete opt . embed ;
315+ }
316+
297317 var file = new pbxFile ( fpath , opt ) ;
298318 file . target = opt ? opt . target : undefined ;
299319
300320 this . removeFromPbxBuildFileSection ( file ) ; // PBXBuildFile
301321 this . removeFromPbxFileReferenceSection ( file ) ; // PBXFileReference
302322 this . removeFromFrameworksPbxGroup ( file ) ; // PBXGroup
303323 this . removeFromPbxFrameworksBuildPhase ( file ) ; // PBXFrameworksBuildPhase
304- this . removeFromPbxEmbedFrameworksBuildPhase ( file ) ; // PBXCopyFilesBuildPhase
305324
306325 if ( opt && opt . customFramework ) {
307326 this . removeFromFrameworkSearchPaths ( file ) ;
308327 }
309328
329+ opt = opt || { } ;
330+ opt . embed = true ;
331+ var embeddedFile = new pbxFile ( fpath , opt ) ;
332+
333+ embeddedFile . fileRef = file . fileRef ;
334+
335+ this . removeFromPbxBuildFileSection ( embeddedFile ) ; // PBXBuildFile
336+ this . removeFromPbxEmbedFrameworksBuildPhase ( embeddedFile ) ; // PBXCopyFilesBuildPhase
337+
310338 return file ;
311339}
312340
@@ -600,12 +628,13 @@ pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
600628pbxProject . prototype . removeFromPbxEmbedFrameworksBuildPhase = function ( file ) {
601629 var sources = this . pbxEmbedFrameworksBuildPhaseObj ( file . target ) ;
602630 if ( sources ) {
631+ var files = [ ] ;
603632 for ( i in sources . files ) {
604- if ( sources . files [ i ] . comment == longComment ( file ) ) {
605- sources . files . splice ( i , 1 ) ;
606- break ;
633+ if ( sources . files [ i ] . comment != longComment ( file ) ) {
634+ files . push ( sources . files [ i ] ) ;
607635 }
608636 }
637+ sources . files = files ;
609638 }
610639}
611640
0 commit comments