Skip to content

Commit 23e1cde

Browse files
committed
cmake-rn: make CODE_SIGNING_ALLOWED configurable for Apple builds
Add a --code-signing-allowed flag to the Apple platform of cmake-rn. CODE_SIGNING_ALLOWED=NO remains the default (needed for the free-standing dynamic libraries we produce), but a consumer who needs signed binaries in the XCFramework - enterprise distribution, or a target whose downstream tooling verifies signatures - can now opt in. Addresses the Apple half of #418. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaK9eAAF5G8wj6UT8VekAm
1 parent c73d30c commit 23e1cde

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

.changeset/silly-cobras-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cmake-rn": minor
3+
---
4+
5+
Add a `--code-signing-allowed` flag to `cmake-rn`. `CODE_SIGNING_ALLOWED=NO` remains the default (needed for the free-standing dynamic libraries we produce), but a consumer who needs signed binaries in the XCFramework can now pass `--code-signing-allowed` to opt in.

packages/cmake-rn/src/platforms/apple.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,15 @@ const appleBundleIdentifierOption = new Option(
161161
"Unique CFBundleIdentifier used for Apple framework artifacts",
162162
).default(undefined, "com.callstackincubator.node-api.{libraryName}");
163163

164+
const codeSigningAllowedOption = new Option(
165+
"--code-signing-allowed",
166+
"Allow code signing when building free dynamic libraries (passed as CODE_SIGNING_ALLOWED to xcodebuild)",
167+
).default(false);
168+
164169
type AppleOpts = {
165170
xcframeworkExtension: boolean;
166171
appleBundleIdentifier?: string;
172+
codeSigningAllowed: boolean;
167173
};
168174

169175
function getBuildPath(baseBuildPath: string, triplet: Triplet) {
@@ -259,7 +265,8 @@ export const platform: Platform<Triplet[], AppleOpts> = {
259265
amendCommand(command) {
260266
return command
261267
.addOption(xcframeworkExtensionOption)
262-
.addOption(appleBundleIdentifierOption);
268+
.addOption(appleBundleIdentifierOption)
269+
.addOption(codeSigningAllowedOption);
263270
},
264271
assertValidTriplets(triplets) {
265272
for (const suffix of SIMULATOR_TRIPLET_SUFFIXES) {
@@ -366,7 +373,7 @@ export const platform: Platform<Triplet[], AppleOpts> = {
366373
},
367374
async build(
368375
{ spawn, triplet },
369-
{ build, target, configuration, appleBundleIdentifier },
376+
{ build, target, configuration, appleBundleIdentifier, codeSigningAllowed },
370377
) {
371378
// We expect the final application to sign these binaries
372379
if (target.length > 1) {
@@ -440,9 +447,10 @@ export const platform: Platform<Triplet[], AppleOpts> = {
440447
...(target.length > 0 ? ["--target", ...target] : []),
441448
"--",
442449

443-
// Skip code-signing (needed when building free dynamic libraries)
444-
// TODO: Make this configurable
445-
"CODE_SIGNING_ALLOWED=NO",
450+
// Skip code-signing by default (needed when building free dynamic
451+
// libraries), but let a consumer opt into signed binaries via
452+
// --code-signing-allowed.
453+
`CODE_SIGNING_ALLOWED=${codeSigningAllowed ? "YES" : "NO"}`,
446454
]);
447455
// Create a framework
448456
const { artifacts } = sharedLibrary;

0 commit comments

Comments
 (0)