#key #apple #bundle #dictionary #launch #version #serializer-deserializer

apple-bundle

用于 Rust 的 Apple BundleResources 序列化和反序列化程序

10 个版本

0.1.4 2022 年 8 月 3 日
0.1.3 2022 年 8 月 3 日
0.1.2 2021 年 6 月 11 日
0.0.5 2021 年 6 月 7 日
0.0.1 2021 年 5 月 27 日

#31 in macOS 和 iOS API

Download history 55/week @ 2024-03-11 31/week @ 2024-03-18 39/week @ 2024-03-25 83/week @ 2024-04-01 74/week @ 2024-04-08 95/week @ 2024-04-15 221/week @ 2024-04-22 126/week @ 2024-04-29 83/week @ 2024-05-06 96/week @ 2024-05-13 171/week @ 2024-05-20 68/week @ 2024-05-27 100/week @ 2024-06-03 194/week @ 2024-06-10 93/week @ 2024-06-17 92/week @ 2024-06-24

481 个月下载量
6 个crate(3 个直接使用)中使用

Apache-2.0

425KB
4.5K SLoC

Apple Bundle Resources

CI Info Crate Info API Docs Crate

AppleBundleResources 序列化和反序列化程序。该库也将随着 Apple Bundle Resources 规范的更改而保持更新。

# Cargo.toml
[dependencies]
apple-bundle = "*"

自己创建 Info.plist

let properties = InfoPlist {
    localization: Localization {
        bundle_development_region: Some("en".to_owned()),
        ..Default::default()
    },
    launch: Launch {
        bundle_executable: Some("test".to_owned()),
        ..Default::default()
    },
    identification: Identification {
        bundle_identifier: "com.test.test-id".to_owned(),
        ..Default::default()
    },
    bundle_version: BundleVersion {
        bundle_version: Some("1".to_owned()),
        bundle_info_dictionary_version: Some("1.0".to_owned()),
        bundle_short_version_string: Some("1.0".to_owned()),
        ..Default::default()
    },
    naming: Naming {
        bundle_name: Some("Test".to_owned()),
        ..Default::default()
    },
    categorization: Categorization {
        bundle_package_type: Some("APPL".to_owned()),
        ..Default::default()
    },
    launch_interface: LaunchInterface {
        launch_storyboard_name: Some("LaunchScreen".to_owned()),
        ..Default::default()
    },
    styling: Styling {
        requires_full_screen: Some(false),
        ..Default::default()
    },
    orientation: Orientation {
        supported_interface_orientations: Some(vec![
            InterfaceOrientation::Portrait,
            InterfaceOrientation::PortraitUpsideDown,
            InterfaceOrientation::LandscapeLeft,
            InterfaceOrientation::LandscapeRight,
        ]),
        ..Default::default()
    },
    ..Default::default()
};
// Create Info.plist file
let file_path = dir.path().join(PLIST_FILE_NAME);
let file = std::fs::File::create(file_path).unwrap();
// Write to Info.plist file
plist::to_writer_xml(file, &properties).unwrap();

或解析任何 Info.plist 文件

pub const PLIST_FILE_EXAMPLE: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleIdentifier</key>
    <string>com.test.test-id</string>
    <key>CFBundleName</key>
    <string>Test</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>1.0</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <false />
    <key>CFBundleExecutable</key>
    <string>test</string>
</dict>
</plist>"#;
// Read from bytes
let properties: InfoPlist = plist::from_bytes(&PLIST_FILE_EXAMPLE.as_bytes()).unwrap();
// Or from file
let file_path = "/path/to/Info.plist";
let properties: InfoPlist = plist::from_file(&file_path).unwrap();

许可证

本项目采用 Apache License,版本 2.0,(LICENSEhttp://www.apache.org/licenses/LICENSE-2.0)。

贡献

除非您明确表示,否则根据 Apache-2.0 许可证定义的,您提交给 toml-rs 的任何有意贡献将按照上述方式双重许可,不附加任何额外条款或条件。

依赖关系

~4.5MB
~83K SLoC