From 09d646668aeb36e61c0dfb3aa32bce068f3adf38 Mon Sep 17 00:00:00 2001 From: Xingchen Yu Date: Thu, 16 Apr 2015 18:15:11 -0400 Subject: [PATCH 1/2] Fixes issue #44, where removeFromPbxFileReferenceSection fails to remove its given file from PBXFileReference. --- lib/pbxProject.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 69ca4f2..f012279 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -277,7 +277,9 @@ pbxProject.prototype.removeFromPbxFileReferenceSection = function (file) { var refObj = pbxFileReferenceObj(file); for(i in this.pbxFileReferenceSection()) { if(this.pbxFileReferenceSection()[i].name == refObj.name || - this.pbxFileReferenceSection()[i].path == refObj.path) { + ('"' + this.pbxFileReferenceSection()[i].name + '"') == refObj.name || + this.pbxFileReferenceSection()[i].path == refObj.path || + ('"' + this.pbxFileReferenceSection()[i].path + '"') == refObj.path) { file.fileRef = file.uuid = i; delete this.pbxFileReferenceSection()[i]; break; From e4d45d76a5075e27527f256202e62386b368df23 Mon Sep 17 00:00:00 2001 From: Xingchen Yu Date: Sat, 18 Apr 2015 12:18:18 -0400 Subject: [PATCH 2/2] Added a unit test to verify correct source file removal from PBXFileReference after being modified by Xcode. --- test/removeSourceFile.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/removeSourceFile.js b/test/removeSourceFile.js index 63c4dfd..e31e727 100644 --- a/test/removeSourceFile.js +++ b/test/removeSourceFile.js @@ -126,6 +126,21 @@ exports.removeSourceFile = { test.ok(!sourceObj); test.done(); + }, + 'should remove file from PBXFileReference after modified by Xcode': function(test) { + var fileRef = proj.addSourceFile('Plugins/file.m').fileRef; + + // Simulate Xcode's behaviour of stripping quotes around path and name + // properties. + var entry = proj.pbxFileReferenceSection()[fileRef]; + entry.name = entry.name.replace(/^"(.*)"$/, "$1"); + entry.path = entry.path.replace(/^"(.*)"$/, "$1"); + + var newFile = proj.removeSourceFile('Plugins/file.m'); + + test.ok(newFile.uuid); + test.ok(!proj.pbxFileReferenceSection()[fileRef]); + test.done(); } }