xcframework/core/
plist.rs1use super::platform::ApplePlatform;
2
3pub struct InfoPlistBuilder {
4 bundle_name: String,
5 platform: ApplePlatform,
6}
7
8impl InfoPlistBuilder {
9 pub fn new(bundle_name: &str, platform: ApplePlatform) -> Self {
10 Self {
11 bundle_name: bundle_name.into(),
12 platform,
13 }
14 }
15
16 pub fn bundle_name(mut self, bundle_name: &str) -> Self {
17 self.bundle_name = bundle_name.to_string();
18 self
19 }
20
21 pub fn platform(mut self, platform: ApplePlatform) -> Self {
22 self.platform = platform;
23 self
24 }
25
26 pub fn write(&self, path: &str) -> std::io::Result<()> {
27 let template = TEAMPLATE
28 .replace("{BUNDLE_NAME}", &self.bundle_name)
29 .replace("{SUPPORTED_PLATFORM}", self.platform.platform_name())
30 .replace("{PLATFORM_NAME}", self.platform.platform_display_name());
31 std::fs::write(path, template)
32 }
33}
34
35const TEAMPLATE: &str = r###"
36<?xml version="1.0" encoding="UTF-8"?>
37<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
38<plist version="1.0">
39<dict>
40 <key>CFBundleExecutable</key>
41 <string>{BUNDLE_NAME}</string>
42 <key>CFBundleIdentifier</key>
43 <string>xcframework.cargo.{BUNDLE_NAME}</string>
44 <key>CFBundleInfoDictionaryVersion</key>
45 <string>6.0</string>
46 <key>CFBundleName</key>
47 <string>{BUNDLE_NAME}</string>
48 <key>CFBundlePackageType</key>
49 <string>APPL</string>
50 <key>CFBundleShortVersionString</key>
51 <string>1.0</string>
52 <key>CFBundleSupportedPlatforms</key>
53 <array>
54 <string>{SUPPORTED_PLATFORM}</string>
55 </array>
56 <key>CFBundleVersion</key>
57 <string>1</string>
58 <key>DTPlatformName</key>
59 <string>{PLATFORM_NAME}</string>
60 <key>DTSDKName</key>
61 <string>iphonesimulator13.0</string>
62 <key>MinimumOSVersion</key>
63 <string>13.0</string>
64</dict>
65</plist>
66"###;