Skip to content

Commit e0aaae0

Browse files
committed
fix: code signing for apps with watchapp
1 parent 0b8108e commit e0aaae0

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

lib/services/ios-project-service.ts

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ interface INativeSourceCodeGroup {
2121
files: string[];
2222
}
2323

24+
enum ProductArgs {
25+
target = "target",
26+
scheme = "scheme"
27+
}
28+
2429
const DevicePlatformSdkName = "iphoneos";
2530
const SimulatorPlatformSdkName = "iphonesimulator";
2631

@@ -215,7 +220,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
215220
const archivePath = options && options.archivePath ? path.resolve(options.archivePath) : path.join(platformData.getBuildOutputPath(buildConfig), projectData.projectName + ".xcarchive");
216221
let args = ["archive", "-archivePath", archivePath, "-configuration",
217222
getConfigurationName(!buildConfig || buildConfig.release)]
218-
.concat(this.xcbuildProjectArgs(projectRoot, projectData, "scheme"));
223+
.concat(this.xcbuildProjectArgs(projectRoot, projectData, ProductArgs.scheme));
219224

220225
if (options && options.additionalArgs) {
221226
args = args.concat(options.additionalArgs);
@@ -329,7 +334,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
329334
return exportFile;
330335
}
331336

332-
private xcbuildProjectArgs(projectRoot: string, projectData: IProjectData, product?: "scheme" | "target"): string[] {
337+
private xcbuildProjectArgs(projectRoot: string, projectData: IProjectData, product?: ProductArgs): string[] {
333338
const xcworkspacePath = path.join(projectRoot, projectData.projectName + ".xcworkspace");
334339
if (this.$fs.exists(xcworkspacePath)) {
335340
return ["-workspace", xcworkspacePath, product ? "-" + product : "-scheme", projectData.projectName];
@@ -403,6 +408,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
403408

404409
args = args.concat((buildConfig && buildConfig.architectures) || this.getBuildArchitectures(projectData, buildConfig, ["armv7", "arm64"]));
405410

411+
if (!this.hasWatchApp(projectData)) {
412+
args = args.concat([
413+
"-sdk", DevicePlatformSdkName
414+
]);
415+
}
416+
406417
args = args.concat([
407418
"BUILD_DIR=" + path.join(projectRoot, constants.BUILD_DIR)
408419
]);
@@ -569,6 +580,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
569580

570581
private async buildForSimulator(projectRoot: string, args: string[], projectData: IProjectData, buildConfig?: IBuildConfig): Promise<void> {
571582
const architectures = this.getBuildArchitectures(projectData, buildConfig, ["i386", "x86_64"]);
583+
let product = ProductArgs.target;
572584

573585
args = args
574586
.concat(architectures)
@@ -577,11 +589,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
577589
"-configuration", getConfigurationName(buildConfig.release),
578590
"ONLY_ACTIVE_ARCH=NO",
579591
"BUILD_DIR=" + path.join(projectRoot, constants.BUILD_DIR),
580-
"CODE_SIGNING_ALLOWED=NO",
581-
"-destination",
582-
"generic/platform=iOS Simulator"
583-
])
584-
.concat(this.xcbuildProjectArgs(projectRoot, projectData, "scheme"));
592+
]);
593+
594+
if (this.hasWatchApp(projectData)) {
595+
product = ProductArgs.scheme;
596+
args = args.concat(["-destination", "generic/platform=iOS Simulator", "CODE_SIGNING_ALLOWED=NO"]);
597+
} else {
598+
args = args.concat(["-sdk", SimulatorPlatformSdkName, "CODE_SIGN_IDENTITY="]);
599+
}
600+
601+
args = args.concat(this.xcbuildProjectArgs(projectRoot, projectData, product));
585602

586603
await this.xcodebuild(args, projectRoot, buildConfig.buildOutputStdio);
587604
}
@@ -779,7 +796,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
779796
const resourcesDirectoryPath = projectData.getAppResourcesDirectoryPath();
780797
const pbxProjPath = this.getPbxProjPath(projectData);
781798
const resourcesNativeCodePath = path.join(
782-
projectData.getAppResourcesDirectoryPath(),
799+
resourcesDirectoryPath,
783800
platformData.normalizedPlatformName,
784801
constants.NATIVE_SOURCE_FOLDER
785802
);
@@ -1387,6 +1404,17 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13871404
"Enterprise": "enterprise"
13881405
}[provision.Type];
13891406
}
1407+
1408+
private hasWatchApp(projectData: IProjectData) {
1409+
const platformData = this.getPlatformData(projectData);
1410+
const watchAppPath = path.join(
1411+
projectData.getAppResourcesDirectoryPath(),
1412+
platformData.normalizedPlatformName,
1413+
constants.IOS_WATCHAPP_FOLDER
1414+
);
1415+
1416+
return this.$fs.exists(watchAppPath);
1417+
}
13901418
}
13911419

13921420
$injector.register("iOSProjectService", IOSProjectService);

0 commit comments

Comments
 (0)