10 releases

0.1.4 Aug 3, 2022
0.1.3 Aug 3, 2022
0.1.2 Jun 11, 2021
0.0.5 Jun 7, 2021
0.0.1 May 27, 2021

#45 in macOS and iOS APIs

Download history 29/week @ 2024-08-02 73/week @ 2024-08-09 49/week @ 2024-08-16 45/week @ 2024-08-23 72/week @ 2024-08-30 102/week @ 2024-09-06 217/week @ 2024-09-13 124/week @ 2024-09-20 66/week @ 2024-09-27 53/week @ 2024-10-04 39/week @ 2024-10-11 155/week @ 2024-10-18 193/week @ 2024-10-25 192/week @ 2024-11-01 54/week @ 2024-11-08 81/week @ 2024-11-15

589 downloads per month
Used in 6 crates (3 directly)

Apache-2.0

425KB
4.5K SLoC

Apple Bundle Resources

CI Info Crate Info API Docs Crate

AppleBundleResources serializer and deserializer for Rust. This library will also likely continue to stay up to date with the official Apple Bundle Resources specification as changes happen.

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

Create Info.plist by yourself:

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();

Or parse any Info.plist file:

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();

License

This project is licensed under Apache License, Version 2.0, (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in toml-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~4.5MB
~82K SLoC