@@ -88,9 +88,7 @@ pbxProject.prototype.addPluginFile = function (path, opt) {
88
88
correctForPluginsPath ( file , this ) ;
89
89
90
90
// null is better for early errors
91
- if ( this . hasFile ( file . path ) ) {
92
- return null ;
93
- }
91
+ if ( this . hasFile ( file . path ) ) return null ;
94
92
95
93
file . fileRef = this . generateUuid ( ) ;
96
94
@@ -103,15 +101,17 @@ pbxProject.prototype.addPluginFile = function (path, opt) {
103
101
pbxProject . prototype . removePluginFile = function ( path , opt ) {
104
102
var file = new pbxFile ( path , opt ) ;
105
103
correctForPluginsPath ( file , this ) ;
106
-
104
+
107
105
this . removeFromPbxFileReferenceSection ( file ) ; // PBXFileReference
108
106
this . removeFromPluginsPbxGroup ( file ) ; // PBXGroup
109
107
110
108
return file ;
111
109
}
112
110
113
111
pbxProject . 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 ;
115
115
116
116
file . uuid = this . generateUuid ( ) ;
117
117
@@ -144,8 +144,10 @@ pbxProject.prototype.addResourceFile = function (path, opt) {
144
144
145
145
if ( opt . plugin ) {
146
146
file = this . addPluginFile ( path , opt ) ;
147
+ if ( ! file ) return false ;
147
148
} else {
148
149
file = new pbxFile ( path , opt ) ;
150
+ if ( this . hasFile ( file . path ) ) return false ;
149
151
}
150
152
151
153
file . uuid = this . generateUuid ( ) ;
@@ -182,6 +184,9 @@ pbxProject.prototype.removeResourceFile = function (path, opt) {
182
184
pbxProject . prototype . addFramework = function ( path , opt ) {
183
185
var file = new pbxFile ( path , opt ) ;
184
186
187
+ // catch duplicates
188
+ if ( this . hasFile ( file . path ) ) return false ;
189
+
185
190
file . uuid = this . generateUuid ( ) ;
186
191
file . fileRef = this . generateUuid ( ) ;
187
192
@@ -211,8 +216,10 @@ pbxProject.prototype.addStaticLibrary = function (path, opt) {
211
216
212
217
if ( opt . plugin ) {
213
218
file = this . addPluginFile ( path , opt ) ;
219
+ if ( ! file ) return false ;
214
220
} else {
215
221
file = new pbxFile ( path , opt ) ;
222
+ if ( this . hasFile ( file . path ) ) return false ;
216
223
}
217
224
218
225
file . uuid = this . generateUuid ( ) ;
@@ -309,7 +316,6 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function (file) {
309
316
}
310
317
}
311
318
312
-
313
319
pbxProject . prototype . addToFrameworksPbxGroup = function ( file ) {
314
320
var pluginsGroup = this . pbxGroupByName ( 'Frameworks' ) ;
315
321
pluginsGroup . children . push ( pbxGroupChild ( file ) ) ;
0 commit comments