@@ -88,9 +88,7 @@ pbxProject.prototype.addPluginFile = function (path, opt) {
8888 correctForPluginsPath ( file , this ) ;
8989
9090 // null is better for early errors
91- if ( this . hasFile ( file . path ) ) {
92- return null ;
93- }
91+ if ( this . hasFile ( file . path ) ) return null ;
9492
9593 file . fileRef = this . generateUuid ( ) ;
9694
@@ -103,15 +101,17 @@ pbxProject.prototype.addPluginFile = function (path, opt) {
103101pbxProject . prototype . removePluginFile = function ( path , opt ) {
104102 var file = new pbxFile ( path , opt ) ;
105103 correctForPluginsPath ( file , this ) ;
106-
104+
107105 this . removeFromPbxFileReferenceSection ( file ) ; // PBXFileReference
108106 this . removeFromPluginsPbxGroup ( file ) ; // PBXGroup
109107
110108 return file ;
111109}
112110
113111pbxProject . prototype . addSourceFile = function ( path , opt ) {
114- var file = this . addPluginFile ( path , opt )
112+ var file = this . addPluginFile ( path , opt ) ;
113+
114+ if ( ! file ) return false ;
115115
116116 file . uuid = this . generateUuid ( ) ;
117117
@@ -144,8 +144,10 @@ pbxProject.prototype.addResourceFile = function (path, opt) {
144144
145145 if ( opt . plugin ) {
146146 file = this . addPluginFile ( path , opt ) ;
147+ if ( ! file ) return false ;
147148 } else {
148149 file = new pbxFile ( path , opt ) ;
150+ if ( this . hasFile ( file . path ) ) return false ;
149151 }
150152
151153 file . uuid = this . generateUuid ( ) ;
@@ -182,6 +184,9 @@ pbxProject.prototype.removeResourceFile = function (path, opt) {
182184pbxProject . prototype . addFramework = function ( path , opt ) {
183185 var file = new pbxFile ( path , opt ) ;
184186
187+ // catch duplicates
188+ if ( this . hasFile ( file . path ) ) return false ;
189+
185190 file . uuid = this . generateUuid ( ) ;
186191 file . fileRef = this . generateUuid ( ) ;
187192
@@ -211,8 +216,10 @@ pbxProject.prototype.addStaticLibrary = function (path, opt) {
211216
212217 if ( opt . plugin ) {
213218 file = this . addPluginFile ( path , opt ) ;
219+ if ( ! file ) return false ;
214220 } else {
215221 file = new pbxFile ( path , opt ) ;
222+ if ( this . hasFile ( file . path ) ) return false ;
216223 }
217224
218225 file . uuid = this . generateUuid ( ) ;
@@ -309,7 +316,6 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function (file) {
309316 }
310317}
311318
312-
313319pbxProject . prototype . addToFrameworksPbxGroup = function ( file ) {
314320 var pluginsGroup = this . pbxGroupByName ( 'Frameworks' ) ;
315321 pluginsGroup . children . push ( pbxGroupChild ( file ) ) ;
0 commit comments