@@ -218,6 +218,7 @@ pbxProject.prototype.addFramework = function(fpath, opt) {
218218 file . fileRef = this . generateUuid ( ) ;
219219 file . target = opt ? opt . target : undefined ;
220220
221+ if ( this . hasFile ( file . path ) ) return false ;
221222
222223 this . addToPbxBuildFileSection ( file ) ; // PBXBuildFile
223224 this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
@@ -1012,15 +1013,24 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) {
10121013 // Setup uuid and name of new target
10131014 var targetUuid = this . generateUuid ( ) ,
10141015 targetType = type ,
1015- targetSubfolder = subfolder ,
1016+ targetSubfolder = subfolder || name ,
10161017 targetName = name . trim ( ) ;
1018+
1019+ // Check type against list of allowed target types
1020+ if ( ! targetName ) {
1021+ throw new Error ( "Target name missing." ) ;
1022+ }
1023+
1024+ // Check type against list of allowed target types
1025+ if ( ! targetType ) {
1026+ throw new Error ( "Target type missing." ) ;
1027+ }
10171028
10181029 // Check type against list of allowed target types
10191030 if ( ! producttypeForTargettype ( targetType ) ) {
1020- console . error ( 'Invalid target type: ' + targetType ) ;
1021- return false
1031+ throw new Error ( "Target type invalid: " + targetType ) ;
10221032 }
1023-
1033+
10241034 // Build Configuration: Create
10251035 var buildConfigurationsList = [
10261036 {
@@ -1131,31 +1141,18 @@ function pbxBuildFileObj(file) {
11311141}
11321142
11331143function pbxFileReferenceObj ( file ) {
1134- var obj = Object . create ( null ) ;
1135-
1136- obj . isa = 'PBXFileReference' ;
1137-
1138- obj . name = "\"" + file . basename + "\"" ;
1139-
1140- if ( file . path ) {
1141- obj . path = "\"" + file . path . replace ( / \\ / g, '/' ) + "\"" ;
1142- }
1143-
1144- obj . sourceTree = file . sourceTree ;
1145-
1146- if ( file . fileEncoding )
1147- obj . fileEncoding = file . fileEncoding ;
1148-
1149- if ( file . lastKnownFileType )
1150- obj . lastKnownFileType = file . lastKnownFileType ;
1151-
1152- if ( file . explicitFileType )
1153- obj . explicitFileType = file . explicitFileType ;
1154-
1155- if ( file . includeInIndex )
1156- obj . includeInIndex = file . includeInIndex ;
1144+ var fileObject = {
1145+ isa : "PBXFileReference" ,
1146+ name : "\"" + file . basename + "\"" ,
1147+ path : "\"" + file . path . replace ( / \\ / g, '/' ) + "\"" ,
1148+ sourceTree : file . sourceTree ,
1149+ fileEncoding : file . fileEncoding ,
1150+ lastKnownFileType : file . lastKnownFileType ,
1151+ explicitFileType : file . explicitFileType ,
1152+ includeInIndex : file . includeInIndex
1153+ } ;
11571154
1158- return obj ;
1155+ return fileObject ;
11591156}
11601157
11611158function pbxGroupChild ( file ) {
0 commit comments