@@ -1711,11 +1711,12 @@ pbxProject.prototype.getFileKey = function(filePath) {
17111711 return false ;
17121712}
17131713
1714- pbxProject . prototype . addTarget = function ( name , type , subfolder , parentTarget ) {
1714+ pbxProject . prototype . addTarget = function ( name , type , subfolder , parentTarget , productTargetType ) {
17151715
17161716 // Setup uuid and name of new target
17171717 var targetUuid = this . generateUuid ( ) ,
17181718 targetType = type ,
1719+ productTargetType = productTargetType || targetType ,
17191720 targetSubfolder = subfolder || name ,
17201721 targetName = name . trim ( ) ;
17211722
@@ -1764,7 +1765,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
17641765
17651766 // Product: Create
17661767 var productName = targetName ,
1767- productType = producttypeForTargettype ( targetType ) ,
1768+ productType = producttypeForTargettype ( productTargetType ) ,
17681769 productFileType = filetypeForProducttype ( productType ) ,
17691770 productFile = this . addProductFile ( productName , { group : 'Copy Files' , 'target' : targetUuid , 'explicitFileType' : productFileType } ) ,
17701771 productFileName = productFile . basename ;
@@ -1792,18 +1793,18 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
17921793 // Target: Add to PBXNativeTarget section
17931794 this . addToPbxNativeTargetSection ( target ) ;
17941795
1795- if ( targetType === 'app_extension' || targetType === 'watch_extension' || targetType === 'watch_app' ) {
1796- const isWatchApp = targetType === 'watch_app' ;
1796+ if ( productTargetType === 'app_extension' || productTargetType === 'watch_extension' || productTargetType === 'watch_app' ) {
1797+ const isWatchApp = productTargetType === 'watch_app' ;
17971798 const copyTargetUuid = parentTarget || this . getFirstTarget ( ) . uuid ;
1798- const phaseComment = targetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files' ;
1799+ const phaseComment = productTargetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files' ;
17991800 let destination ;
18001801
18011802 if ( isWatchApp ) {
18021803 destination = '"$(CONTENTS_FOLDER_PATH)/Watch"' ;
18031804 }
18041805
18051806 // Create CopyFiles phase in parent target
1806- this . addBuildPhase ( [ ] , 'PBXCopyFilesBuildPhase' , phaseComment , copyTargetUuid , targetType , destination ) ;
1807+ this . addBuildPhase ( [ ] , 'PBXCopyFilesBuildPhase' , phaseComment , copyTargetUuid , productTargetType , destination ) ;
18071808
18081809 // Add product to CopyFiles phase
18091810 this . addToPbxCopyfilesBuildPhase ( productFile , phaseComment , copyTargetUuid ) ;
0 commit comments