Skip to content

Commit 0b59e7c

Browse files
committed
Add Info.plist to framework
1 parent 1a2730e commit 0b59e7c

File tree

1 file changed

+31
-0
lines changed
  • packages/react-native-node-api-cmake/src

1 file changed

+31
-0
lines changed

packages/react-native-node-api-cmake/src/apple.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ export function getAppleSDKPath(triplet: AppleTriplet) {
8282
.stdout.trim();
8383
}
8484

85+
export function createPlistContent(values: Record<string, string>) {
86+
return [
87+
'<?xml version="1.0" encoding="UTF-8"?>',
88+
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
89+
'<plist version="1.0">',
90+
"<dict>",
91+
...Object.entries(values).flatMap(([key, value]) => [
92+
`<key>${key}</key>`,
93+
`<string>${value}</string>`,
94+
]),
95+
"</dict>",
96+
"</plist>",
97+
].join("\n");
98+
}
99+
85100
export function getAppleConfigureCmakeArgs(triplet: AppleTriplet) {
86101
assert(isAppleTriplet(triplet));
87102
const sdkPath = getAppleSDKPath(triplet);
@@ -125,6 +140,22 @@ export function createFramework(libraryPath: string) {
125140
fs.rmSync(frameworkPath, { recursive: true, force: true });
126141
fs.mkdirSync(frameworkPath);
127142
fs.mkdirSync(path.join(frameworkPath, "Headers"));
143+
// Create an empty Info.plist file
144+
fs.writeFileSync(
145+
path.join(frameworkPath, "Info.plist"),
146+
createPlistContent({
147+
CFBundleDevelopmentRegion: "en",
148+
CFBundleExecutable: libraryName,
149+
CFBundleIdentifier: `com.callstackincubator.node-api.${libraryName}`,
150+
CFBundleInfoDictionaryVersion: "6.0",
151+
CFBundleName: libraryName,
152+
CFBundlePackageType: "FMWK",
153+
CFBundleShortVersionString: "1.0",
154+
CFBundleVersion: "1",
155+
NSPrincipalClass: "",
156+
}),
157+
"utf8"
158+
);
128159
const newLibraryPath = path.join(frameworkPath, libraryName);
129160
fs.renameSync(libraryPath, newLibraryPath);
130161
// Update the name of the library

0 commit comments

Comments
 (0)