Skip to content

Commit 57a97a3

Browse files
committed
fix: code signing for apps with watchapp
1 parent 25bf41a commit 57a97a3

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

lib/services/ios-project-service.ts

+36-8
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);
@@ -340,7 +345,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
340345
return exportFile;
341346
}
342347

343-
private xcbuildProjectArgs(projectRoot: string, projectData: IProjectData, product?: "scheme" | "target"): string[] {
348+
private xcbuildProjectArgs(projectRoot: string, projectData: IProjectData, product?: ProductArgs): string[] {
344349
const xcworkspacePath = path.join(projectRoot, projectData.projectName + ".xcworkspace");
345350
if (this.$fs.exists(xcworkspacePath)) {
346351
return ["-workspace", xcworkspacePath, product ? "-" + product : "-scheme", projectData.projectName];
@@ -414,6 +419,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
414419

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

422+
if (!this.hasWatchApp(projectData)) {
423+
args = args.concat([
424+
"-sdk", DevicePlatformSdkName
425+
]);
426+
}
427+
417428
args = args.concat([
418429
"BUILD_DIR=" + path.join(projectRoot, constants.BUILD_DIR)
419430
]);
@@ -580,6 +591,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
580591

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

584596
args = args
585597
.concat(architectures)
@@ -588,11 +600,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
588600
"-configuration", getConfigurationName(buildConfig.release),
589601
"ONLY_ACTIVE_ARCH=NO",
590602
"BUILD_DIR=" + path.join(projectRoot, constants.BUILD_DIR),
591-
"CODE_SIGNING_ALLOWED=NO",
592-
"-destination",
593-
"generic/platform=iOS Simulator"
594-
])
595-
.concat(this.xcbuildProjectArgs(projectRoot, projectData, "scheme"));
603+
]);
604+
605+
if (this.hasWatchApp(projectData)) {
606+
product = ProductArgs.scheme;
607+
args = args.concat(["-destination", "generic/platform=iOS Simulator", "CODE_SIGNING_ALLOWED=NO"]);
608+
} else {
609+
args = args.concat(["-sdk", SimulatorPlatformSdkName, "CODE_SIGN_IDENTITY="]);
610+
}
611+
612+
args = args.concat(this.xcbuildProjectArgs(projectRoot, projectData, product));
596613

597614
await this.xcodebuild(args, projectRoot, buildConfig.buildOutputStdio);
598615
}
@@ -790,7 +807,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
790807
const resourcesDirectoryPath = projectData.getAppResourcesDirectoryPath();
791808
const pbxProjPath = this.getPbxProjPath(projectData);
792809
const resourcesNativeCodePath = path.join(
793-
projectData.getAppResourcesDirectoryPath(),
810+
resourcesDirectoryPath,
794811
platformData.normalizedPlatformName,
795812
constants.NATIVE_SOURCE_FOLDER
796813
);
@@ -1398,6 +1415,17 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13981415
"Enterprise": "enterprise"
13991416
}[provision.Type];
14001417
}
1418+
1419+
private hasWatchApp(projectData: IProjectData) {
1420+
const platformData = this.getPlatformData(projectData);
1421+
const watchAppPath = path.join(
1422+
projectData.getAppResourcesDirectoryPath(),
1423+
platformData.normalizedPlatformName,
1424+
constants.IOS_WATCHAPP_FOLDER
1425+
);
1426+
1427+
return this.$fs.exists(watchAppPath);
1428+
}
14011429
}
14021430

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

0 commit comments

Comments
 (0)