xcodeproj/pbxproj/object/build/phase/
file.rs

1use crate::pbxproj::*;
2
3/// [`PBXObject`] A File referenced by a build phase, unique to each build phase.
4#[derive(Default, Debug, derive_new::new, derive_deref_rs::Deref)]
5pub struct PBXBuildFile<'a> {
6    /// ID Reference
7    pub id: String,
8    /// Element settings
9    pub settings: Option<&'a PBXValue>,
10    /// Platform filter attribute.
11    pub platform_filter: Option<&'a String>,
12    /// Element file reference.
13    #[deref]
14    pub file: Option<PBXFSReference<'a>>,
15    /// Product reference.
16    pub product: Option<XCSwiftPackageProductDependency<'a>>,
17    /// The cached build phase this build file belongs to
18    pub build_phase: Option<PBXBuildPhase<'a>>,
19}
20
21impl<'a> AsPBXObject<'a> for PBXBuildFile<'a> {
22    fn as_pbx_object(
23        id: String,
24        value: &'a PBXHashMap,
25        objects: &'a PBXObjectCollection,
26    ) -> anyhow::Result<Self>
27    where
28        Self: Sized + 'a,
29    {
30        Ok(Self {
31            id,
32            settings: value.get_value("settings"),
33            platform_filter: value.get_string("platformFilter"),
34            file: value.get_string("fileRef").and_then(|k| objects.get(k)),
35            product: value.get_string("productRef").and_then(|k| objects.get(k)),
36            build_phase: value
37                .get_string("buildPhaseReference")
38                .and_then(|k| objects.get(k)),
39        })
40    }
41}