1
+ import path from 'path' ;
1
2
import color from 'picocolors' ;
2
3
import { XcodeProjectType } from 'xcode' ;
3
4
import { Constants } from '../../constants' ;
@@ -10,7 +11,7 @@ import { addGCCapability } from './xcodeTask.addCapability.gc';
10
11
import { addGroupsCapability } from './xcodeTask.addCapability.groups' ;
11
12
import { addKSCapability } from './xcodeTask.addCapability.ks' ;
12
13
import { addMapsCapability } from './xcodeTask.addCapability.maps' ;
13
- import { patchXcodeProject } from './xcodeTask.helpers' ;
14
+ import { patchXcodeProject , unquote } from './xcodeTask.helpers' ;
14
15
15
16
export function applyAddCapability (
16
17
content : XcodeProjectType ,
@@ -36,15 +37,16 @@ export function applyAddCapability(
36
37
break ;
37
38
}
38
39
const groupObj = content . getPBXGroupByKey ( group ) ;
39
- const filename = groupObj . name + '.entitlements' ;
40
+ const groupName = groupObj . name || path . basename ( groupObj . path ) ;
41
+ const filename = groupName + '.entitlements' ;
40
42
destination += `/${ filename } ` ;
41
- const isAdded = groupObj . children . some ( x => x . comment == filename ) ;
43
+ const isAdded = groupObj . children . some ( x => unquote ( x . comment ) == filename ) ;
42
44
if ( ! isAdded ) {
43
45
const releasePatch = patchXcodeProject ( {
44
46
push : ( array , item ) => array . unshift ( item ) ,
45
47
} ) ;
46
48
try {
47
- content . addFile ( `${ groupObj . name } /${ filename } ` , group , {
49
+ content . addFile ( `${ groupName } /${ filename } ` , group , {
48
50
target : nativeTarget . uuid ,
49
51
lastKnownFileType : 'text.plist.entitlements' ,
50
52
} ) ;
@@ -53,15 +55,15 @@ export function applyAddCapability(
53
55
}
54
56
content . updateBuildProperty (
55
57
'CODE_SIGN_ENTITLEMENTS' ,
56
- `${ groupObj . name } /${ filename } ` ,
58
+ `${ groupName } /${ filename } ` ,
57
59
null ,
58
- groupObj . name
60
+ groupName
59
61
) ;
60
62
content . updateBuildProperty (
61
63
'CODE_SIGN_ENTITLEMENTS' ,
62
- `${ groupObj . name } /${ filename } ` ,
64
+ `${ groupName } /${ filename } ` ,
63
65
null ,
64
- '"' + groupObj . name + '"'
66
+ '"' + groupName + '"'
65
67
) ;
66
68
}
67
69
switch ( addCapability ) {
@@ -76,49 +78,49 @@ export function applyAddCapability(
76
78
addCommonCapability ( {
77
79
destination,
78
80
filename,
79
- targetName : groupObj . name ,
81
+ targetName : groupName ,
80
82
capability : addCapability ,
81
83
} ) ;
82
84
break ;
83
85
case 'groups' :
84
86
addGroupsCapability ( {
85
87
destination,
86
88
filename,
87
- targetName : groupObj . name ,
89
+ targetName : groupName ,
88
90
groups : action . groups ,
89
91
} ) ;
90
92
break ;
91
93
case 'background-mode' :
92
94
addBMCapability ( {
93
- targetName : groupObj . name ,
95
+ targetName : groupName ,
94
96
modes : action . modes ,
95
97
} ) ;
96
98
break ;
97
99
case 'game-controllers' :
98
100
addGCCapability ( {
99
- targetName : groupObj . name ,
101
+ targetName : groupName ,
100
102
controllers : action . controllers ,
101
103
} ) ;
102
104
break ;
103
105
case 'maps' :
104
106
addMapsCapability ( {
105
- targetName : groupObj . name ,
107
+ targetName : groupName ,
106
108
routing : action . routing ,
107
109
} ) ;
108
110
break ;
109
111
case 'keychain-sharing' :
110
112
addKSCapability ( {
111
113
destination,
112
114
filename,
113
- targetName : groupObj . name ,
115
+ targetName : groupName ,
114
116
groups : action . groups ,
115
117
} ) ;
116
118
break ;
117
119
}
118
120
119
121
logMessage (
120
122
`added ${ color . yellow ( addCapability ) } capability to the ${ color . yellow (
121
- groupObj . name
123
+ groupName
122
124
) } target`
123
125
) ;
124
126
0 commit comments