@@ -435,8 +435,8 @@ pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function(target) {
435
435
return this . buildPhaseObject ( 'PBXCopyFilesBuildPhase' , 'Copy Files' , target ) ;
436
436
}
437
437
438
- pbxProject . prototype . addToPbxCopyfilesBuildPhase = function ( file ) {
439
- var sources = this . buildPhaseObject ( 'PBXCopyFilesBuildPhase' , 'Copy Files' , file . target ) ;
438
+ pbxProject . prototype . addToPbxCopyfilesBuildPhase = function ( file , comment , target ) {
439
+ var sources = this . buildPhaseObject ( 'PBXCopyFilesBuildPhase' , comment || 'Copy Files' , target || file . target ) ;
440
440
sources . files . push ( pbxBuildPhaseObj ( file ) ) ;
441
441
}
442
442
@@ -1616,7 +1616,7 @@ pbxProject.prototype.getFileKey = function(filePath) {
1616
1616
return false ;
1617
1617
}
1618
1618
1619
- pbxProject . prototype . addTarget = function ( name , type , subfolder ) {
1619
+ pbxProject . prototype . addTarget = function ( name , type , subfolder , parentTarget ) {
1620
1620
1621
1621
// Setup uuid and name of new target
1622
1622
var targetUuid = this . generateUuid ( ) ,
@@ -1695,26 +1695,30 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) {
1695
1695
} ;
1696
1696
1697
1697
// Target: Add to PBXNativeTarget section
1698
- this . addToPbxNativeTargetSection ( target )
1698
+ this . addToPbxNativeTargetSection ( target ) ;
1699
1699
1700
- // Product: Embed (only for "extension"-type targets)
1701
- if ( targetType === 'app_extension' ) {
1700
+ if ( targetType === 'app_extension' || targetType === 'watch_extension' || targetType === 'watch_app' ) {
1701
+ const isWatchApp = targetType === 'watch_app' ;
1702
+ const copyTargetUuid = parentTarget || this . getFirstTarget ( ) . uuid ;
1703
+ const phaseComment = targetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files' ;
1704
+ let destination ;
1702
1705
1703
- // Create CopyFiles phase in first target
1704
- this . addBuildPhase ( [ ] , 'PBXCopyFilesBuildPhase' , 'Copy Files' , this . getFirstTarget ( ) . uuid , targetType )
1705
-
1706
- // Add product to CopyFiles phase
1707
- this . addToPbxCopyfilesBuildPhase ( productFile )
1706
+ if ( isWatchApp ) {
1707
+ destination = '"$(CONTENTS_FOLDER_PATH)/Watch"' ;
1708
+ }
1708
1709
1709
- // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid)
1710
+ // Create CopyFiles phase in parent target
1711
+ this . addBuildPhase ( [ ] , 'PBXCopyFilesBuildPhase' , phaseComment , copyTargetUuid , targetType , destination ) ;
1710
1712
1713
+ // Add product to CopyFiles phase
1714
+ this . addToPbxCopyfilesBuildPhase ( productFile , phaseComment , copyTargetUuid ) ;
1711
1715
}
1712
1716
1713
1717
// Target: Add uuid to root project
1714
1718
this . addToPbxProjectSection ( target ) ;
1715
1719
1716
1720
// Target: Add dependency for this target to first (main) target
1717
- this . addTargetDependency ( this . getFirstTarget ( ) . uuid , [ target . uuid ] ) ;
1721
+ this . addTargetDependency ( parentTarget || this . getFirstTarget ( ) . uuid , [ target . uuid ] ) ;
1718
1722
1719
1723
1720
1724
// Return target on success
@@ -2005,7 +2009,7 @@ function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) {
2005
2009
frameworks : 'frameworks' ,
2006
2010
static_library : 'products_directory' ,
2007
2011
unit_test_bundle : 'wrapper' ,
2008
- watch_app : 'wrapper ' ,
2012
+ watch_app : 'products_directory ' ,
2009
2013
watch_extension : 'plugins'
2010
2014
}
2011
2015
var SUBFOLDERSPEC_BY_DESTINATION = {
@@ -2161,8 +2165,8 @@ function producttypeForTargettype (targetType) {
2161
2165
framework : 'com.apple.product-type.framework' ,
2162
2166
static_library : 'com.apple.product-type.library.static' ,
2163
2167
unit_test_bundle : 'com.apple.product-type.bundle.unit-test' ,
2164
- watch_app : 'com.apple.product-type.application.watchapp ' ,
2165
- watch_extension : 'com.apple.product-type.watchkit -extension'
2168
+ watch_app : 'com.apple.product-type.application.watchapp2 ' ,
2169
+ watch_extension : 'com.apple.product-type.watchkit2 -extension'
2166
2170
} ;
2167
2171
2168
2172
return PRODUCTTYPE_BY_TARGETTYPE [ targetType ]
@@ -2179,8 +2183,8 @@ function filetypeForProducttype (productType) {
2179
2183
'com.apple.product-type.framework' : '"wrapper.framework"' ,
2180
2184
'com.apple.product-type.library.static' : '"archive.ar"' ,
2181
2185
'com.apple.product-type.bundle.unit-test' : '"wrapper.cfbundle"' ,
2182
- 'com.apple.product-type.application.watchapp ' : '"wrapper.application"' ,
2183
- 'com.apple.product-type.watchkit -extension' : '"wrapper.app-extension"'
2186
+ 'com.apple.product-type.application.watchapp2 ' : '"wrapper.application"' ,
2187
+ 'com.apple.product-type.watchkit2 -extension' : '"wrapper.app-extension"'
2184
2188
} ;
2185
2189
2186
2190
return FILETYPE_BY_PRODUCTTYPE [ productType ]
0 commit comments