Skip to content

Commit 8899c8e

Browse files
committed
fix: visionos build cert
1 parent a806c20 commit 8899c8e

File tree

3 files changed

+95
-75
lines changed

3 files changed

+95
-75
lines changed

lib/services/ios/ios-signing-service.ts

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as helpers from "../../common/helpers";
99
import { IOSProvisionService } from "../ios-provision-service";
1010
import { IOSBuildData } from "../../data/build-data";
1111
import {
12+
IOptions,
1213
IProvisioningJSON,
1314
IXcconfigService,
1415
IXcprojService,
@@ -25,19 +26,20 @@ export class IOSSigningService implements IiOSSigningService {
2526
private $fs: IFileSystem,
2627
private $iOSProvisionService: IOSProvisionService,
2728
private $logger: ILogger,
29+
private $options: IOptions,
2830
private $pbxprojDomXcode: IPbxprojDomXcode,
2931
private $prompter: IPrompter,
3032
private $xcconfigService: IXcconfigService,
31-
private $xcprojService: IXcprojService
33+
private $xcprojService: IXcprojService,
3234
) {}
3335

3436
public async setupSigningForDevice(
3537
projectRoot: string,
3638
projectData: IProjectData,
37-
iOSBuildData: IOSBuildData
39+
iOSBuildData: IOSBuildData,
3840
): Promise<void> {
3941
const xcode = this.$pbxprojDomXcode.Xcode.open(
40-
this.getPbxProjPath(projectData, projectRoot)
42+
this.getPbxProjPath(projectData, projectRoot),
4143
);
4244
const signing = xcode.getSigning(projectData.projectName);
4345

@@ -63,7 +65,7 @@ export class IOSSigningService implements IiOSSigningService {
6365
const teamId = await this.getDevelopmentTeam(
6466
projectData,
6567
projectRoot,
66-
iOSBuildData.teamId
68+
iOSBuildData.teamId,
6769
);
6870
await this.setupSigningFromTeam(projectRoot, projectData, teamId);
6971
}
@@ -72,10 +74,10 @@ export class IOSSigningService implements IiOSSigningService {
7274
public async setupSigningFromTeam(
7375
projectRoot: string,
7476
projectData: IProjectData,
75-
teamId: string
77+
teamId: string,
7678
): Promise<void> {
7779
const xcode = this.$pbxprojDomXcode.Xcode.open(
78-
this.getPbxProjPath(projectData, projectRoot)
80+
this.getPbxProjPath(projectData, projectRoot),
7981
);
8082
const signing = xcode.getSigning(projectData.projectName);
8183

@@ -94,12 +96,11 @@ export class IOSSigningService implements IiOSSigningService {
9496
}
9597

9698
if (shouldUpdateXcode) {
97-
const teamIdsForName = await this.$iOSProvisionService.getTeamIdsWithName(
98-
teamId
99-
);
99+
const teamIdsForName =
100+
await this.$iOSProvisionService.getTeamIdsWithName(teamId);
100101
if (teamIdsForName.length > 0) {
101102
this.$logger.trace(
102-
`Team id ${teamIdsForName[0]} will be used for team name "${teamId}".`
103+
`Team id ${teamIdsForName[0]} will be used for team name "${teamId}".`,
103104
);
104105
teamId = teamIdsForName[0];
105106
}
@@ -111,7 +112,7 @@ export class IOSSigningService implements IiOSSigningService {
111112
IOSNativeTargetProductTypes.watchApp,
112113
IOSNativeTargetProductTypes.watchExtension,
113114
],
114-
teamId
115+
teamId,
115116
);
116117
this.getExtensionNames(projectData).forEach((name) => {
117118
xcode.setAutomaticSigningStyle(name, teamId);
@@ -122,7 +123,7 @@ export class IOSSigningService implements IiOSSigningService {
122123
this.$logger.trace(`Set Automatic signing style and team id ${teamId}.`);
123124
} else {
124125
this.$logger.trace(
125-
`The specified ${teamId} is already set in the Xcode.`
126+
`The specified ${teamId} is already set in the Xcode.`,
126127
);
127128
}
128129
}
@@ -131,15 +132,15 @@ export class IOSSigningService implements IiOSSigningService {
131132
projectRoot: string,
132133
projectData: IProjectData,
133134
provision?: string,
134-
mobileProvisionData?: mobileProvisionFinder.provision.MobileProvision
135+
mobileProvisionData?: mobileProvisionFinder.provision.MobileProvision,
135136
): Promise<void> {
136137
if (!provision) {
137138
// read uuid from Xcode an cache...
138139
return;
139140
}
140141

141142
const xcode = this.$pbxprojDomXcode.Xcode.open(
142-
this.getPbxProjPath(projectData, projectRoot)
143+
this.getPbxProjPath(projectData, projectRoot),
143144
);
144145
const signing = xcode.getSigning(projectData.projectName);
145146

@@ -160,40 +161,40 @@ export class IOSSigningService implements IiOSSigningService {
160161
const projectSigningConfig = await this.getManualSigningConfiguration(
161162
projectData,
162163
provision,
163-
mobileProvisionData
164+
mobileProvisionData,
164165
);
165166
xcode.setManualSigningStyle(
166167
projectData.projectName,
167-
projectSigningConfig
168+
projectSigningConfig,
168169
);
169170
xcode.setManualSigningStyleByTargetProductTypesList(
170171
[
171172
IOSNativeTargetProductTypes.appExtension,
172173
IOSNativeTargetProductTypes.watchApp,
173174
IOSNativeTargetProductTypes.watchExtension,
174175
],
175-
projectSigningConfig
176+
projectSigningConfig,
176177
);
177178

178179
this.$logger.trace(
179-
`Set Manual signing style and provisioning profile: ${projectSigningConfig.name} (${projectSigningConfig.uuid})`
180+
`Set Manual signing style and provisioning profile: ${projectSigningConfig.name} (${projectSigningConfig.uuid})`,
180181
);
181182

182183
const extensionSigningConfig = await Promise.all(
183-
this.getExtensionsManualSigningConfiguration(projectData)
184+
this.getExtensionsManualSigningConfiguration(projectData),
184185
);
185186
extensionSigningConfig.forEach(({ name, configuration }) => {
186187
xcode.setManualSigningStyle(name, configuration);
187188
this.$logger.trace(
188-
`Set Manual signing style and provisioning profile: ${configuration.name} (${configuration.uuid})`
189+
`Set Manual signing style and provisioning profile: ${configuration.name} (${configuration.uuid})`,
189190
);
190191
});
191192

192193
xcode.save();
193194
// this.cache(uuid);
194195
} else {
195196
this.$logger.trace(
196-
`The specified provisioning profile is already set in the Xcode: ${provision}`
197+
`The specified provisioning profile is already set in the Xcode: ${provision}`,
197198
);
198199
}
199200
}
@@ -202,7 +203,7 @@ export class IOSSigningService implements IiOSSigningService {
202203
const extensionFolderPath = path.join(
203204
projectData.getAppResourcesDirectoryPath(),
204205
constants.iOSAppResourcesFolderName,
205-
constants.NATIVE_EXTENSION_FOLDER
206+
constants.NATIVE_EXTENSION_FOLDER,
206207
);
207208

208209
if (this.$fs.exists(extensionFolderPath)) {
@@ -223,12 +224,12 @@ export class IOSSigningService implements IiOSSigningService {
223224
projectData.getAppResourcesDirectoryPath(),
224225
constants.iOSAppResourcesFolderName,
225226
constants.NATIVE_EXTENSION_FOLDER,
226-
constants.EXTENSION_PROVISIONING_FILENAME
227+
constants.EXTENSION_PROVISIONING_FILENAME,
227228
);
228229

229230
if (this.$fs.exists(provisioningJSONPath)) {
230231
const provisioningJSON = this.$fs.readJson(
231-
provisioningJSONPath
232+
provisioningJSONPath,
232233
) as IProvisioningJSON;
233234

234235
const extensionNames = this.getExtensionNames(projectData);
@@ -239,12 +240,12 @@ export class IOSSigningService implements IiOSSigningService {
239240
if (extensionNames.includes(name)) {
240241
const configuration = await this.getManualSigningConfiguration(
241242
projectData,
242-
provision
243+
provision,
243244
);
244245
return { name, configuration };
245246
}
246247
return null;
247-
}
248+
},
248249
);
249250

250251
return provisioning;
@@ -256,28 +257,30 @@ export class IOSSigningService implements IiOSSigningService {
256257
private async getManualSigningConfiguration(
257258
projectData: IProjectData,
258259
provision: string,
259-
mobileProvisionData?: mobileProvisionFinder.provision.MobileProvision
260+
mobileProvisionData?: mobileProvisionFinder.provision.MobileProvision,
260261
) {
261262
const pickStart = Date.now();
262263
const mobileprovision =
263264
mobileProvisionData ||
264265
(await this.$iOSProvisionService.pick(
265266
provision,
266-
projectData.projectIdentifiers.ios
267+
projectData.projectIdentifiers.ios,
267268
));
268269
const pickEnd = Date.now();
269270
this.$logger.trace(
270271
"Searched and " +
271272
(mobileprovision ? "found" : "failed to find ") +
272273
" matching provisioning profile. (" +
273274
(pickEnd - pickStart) +
274-
"ms.)"
275+
"ms.)",
275276
);
276277
if (!mobileprovision) {
277278
this.$errors.fail(
278-
"Failed to find mobile provision with UUID or Name: " + provision
279+
"Failed to find mobile provision with UUID or Name: " + provision,
279280
);
280281
}
282+
const isVisionOS =
283+
this.$options.platformOverride?.toLowerCase() === "visionos";
281284
const configuration = {
282285
team:
283286
mobileprovision.TeamIdentifier &&
@@ -288,8 +291,12 @@ export class IOSSigningService implements IiOSSigningService {
288291
name: mobileprovision.Name,
289292
identity:
290293
mobileprovision.Type === "Development"
291-
? "iPhone Developer"
292-
: "iPhone Distribution",
294+
? isVisionOS
295+
? "Apple Development"
296+
: "iPhone Developer"
297+
: isVisionOS
298+
? "Apple Distribution"
299+
: "iPhone Distribution",
293300
};
294301
return configuration;
295302
}
@@ -298,17 +305,17 @@ export class IOSSigningService implements IiOSSigningService {
298305
return path.join(
299306
projectData.appResourcesDirectoryPath,
300307
iOSAppResourcesFolderName,
301-
BUILD_XCCONFIG_FILE_NAME
308+
BUILD_XCCONFIG_FILE_NAME,
302309
);
303310
}
304311

305312
private getPbxProjPath(
306313
projectData: IProjectData,
307-
projectRoot: string
314+
projectRoot: string,
308315
): string {
309316
return path.join(
310317
this.$xcprojService.getXcodeprojPath(projectData, projectRoot),
311-
"project.pbxproj"
318+
"project.pbxproj",
312319
);
313320
}
314321
private readTeamIdFromFile(projectRoot: string): string | undefined {
@@ -325,17 +332,17 @@ export class IOSSigningService implements IiOSSigningService {
325332
private async getDevelopmentTeam(
326333
projectData: IProjectData,
327334
projectRoot: string,
328-
teamId?: string
335+
teamId?: string,
329336
): Promise<string> {
330337
teamId = teamId || this.readXCConfigDevelopmentTeam(projectData);
331338

332339
if (!teamId) {
333340
const teams = await this.$iOSProvisionService.getDevelopmentTeams();
334341
this.$logger.warn(
335-
"Xcode requires a team id to be specified when building for device."
342+
"Xcode requires a team id to be specified when building for device.",
336343
);
337344
this.$logger.warn(
338-
"You can specify the team id by setting the DEVELOPMENT_TEAM setting in build.xcconfig file located in App_Resources folder of your app, or by using the --teamId option when calling run, debug or livesync commands."
345+
"You can specify the team id by setting the DEVELOPMENT_TEAM setting in build.xcconfig file located in App_Resources folder of your app, or by using the --teamId option when calling run, debug or livesync commands.",
339346
);
340347
if (teams.length === 1) {
341348
teamId = teams[0].id;
@@ -344,15 +351,15 @@ export class IOSSigningService implements IiOSSigningService {
344351
teams[0].name +
345352
" (" +
346353
teams[0].id +
347-
")"
354+
")",
348355
);
349356
} else if (teams.length > 0) {
350357
if (!helpers.isInteractive()) {
351358
this.$errors.fail(
352359
`Unable to determine default development team. Available development teams are: ${_.map(
353360
teams,
354-
(team) => team.id
355-
)}. Specify team in app/App_Resources/iOS/build.xcconfig file in the following way: DEVELOPMENT_TEAM = <team id>`
361+
(team) => team.id,
362+
)}. Specify team in app/App_Resources/iOS/build.xcconfig file in the following way: DEVELOPMENT_TEAM = <team id>`,
356363
);
357364
}
358365
const fromFile = this.readTeamIdFromFile(projectRoot);
@@ -370,7 +377,7 @@ export class IOSSigningService implements IiOSSigningService {
370377
}
371378
const choice = await this.$prompter.promptForChoice(
372379
"Found multiple development teams, select one:",
373-
choices
380+
choices,
374381
);
375382
teamId = teams[choices.indexOf(choice)].id;
376383

@@ -383,18 +390,18 @@ export class IOSSigningService implements IiOSSigningService {
383390
"Do you want to make teamId: " +
384391
teamId +
385392
" a persistent choice for your app?",
386-
choicesPersist
393+
choicesPersist,
387394
);
388395
switch (choicesPersist.indexOf(choicePersist)) {
389396
case 0:
390397
const xcconfigFile = path.join(
391398
projectData.appResourcesDirectoryPath,
392399
"iOS",
393-
BUILD_XCCONFIG_FILE_NAME
400+
BUILD_XCCONFIG_FILE_NAME,
394401
);
395402
this.$fs.appendFile(
396403
xcconfigFile,
397-
"\nDEVELOPMENT_TEAM = " + teamId + "\n"
404+
"\nDEVELOPMENT_TEAM = " + teamId + "\n",
398405
);
399406
break;
400407
case 1:
@@ -415,41 +422,41 @@ export class IOSSigningService implements IiOSSigningService {
415422
private readXCConfigDevelopmentTeam(projectData: IProjectData): string {
416423
return this.$xcconfigService.readPropertyValue(
417424
this.getBuildXCConfigFilePath(projectData),
418-
"DEVELOPMENT_TEAM"
425+
"DEVELOPMENT_TEAM",
419426
);
420427
}
421428

422429
private readXCConfigProvisioningProfile(projectData: IProjectData): string {
423430
return this.$xcconfigService.readPropertyValue(
424431
this.getBuildXCConfigFilePath(projectData),
425-
"PROVISIONING_PROFILE"
432+
"PROVISIONING_PROFILE",
426433
);
427434
}
428435

429436
private readXCConfigProvisioningProfileForIPhoneOs(
430-
projectData: IProjectData
437+
projectData: IProjectData,
431438
): string {
432439
return this.$xcconfigService.readPropertyValue(
433440
this.getBuildXCConfigFilePath(projectData),
434-
"PROVISIONING_PROFILE[sdk=iphoneos*]"
441+
"PROVISIONING_PROFILE[sdk=iphoneos*]",
435442
);
436443
}
437444

438445
private readXCConfigProvisioningProfileSpecifier(
439-
projectData: IProjectData
446+
projectData: IProjectData,
440447
): string {
441448
return this.$xcconfigService.readPropertyValue(
442449
this.getBuildXCConfigFilePath(projectData),
443-
"PROVISIONING_PROFILE_SPECIFIER"
450+
"PROVISIONING_PROFILE_SPECIFIER",
444451
);
445452
}
446453

447454
private readXCConfigProvisioningProfileSpecifierForIPhoneOs(
448-
projectData: IProjectData
455+
projectData: IProjectData,
449456
): string {
450457
return this.$xcconfigService.readPropertyValue(
451458
this.getBuildXCConfigFilePath(projectData),
452-
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]"
459+
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]",
453460
);
454461
}
455462
}

0 commit comments

Comments
 (0)