Skip to content

Commit

Permalink
feat: helper function to generate hashmap of target names and platform
Browse files Browse the repository at this point in the history
  • Loading branch information
kkharji committed Jun 19, 2022
1 parent d06cba8 commit 04a8732
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pbxproj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ pub use object::*;
pub use value::*;

use anyhow::Result;
use std::path::{Path, PathBuf};
use std::{
collections::HashMap,
path::{Path, PathBuf},
};
use tap::Pipe;

/// `Main` Representation of project.pbxproj file
Expand Down Expand Up @@ -76,6 +79,14 @@ impl PBXRootObject {
pub fn objects_mut(&mut self) -> &mut PBXObjectCollection {
&mut self.objects
}

/// Get a hashmap of targets and their platform
pub fn targets_platform(&self) -> HashMap<String, PBXTargetPlatform> {
self.targets()
.into_iter()
.flat_map(|t| Some((t.name?.to_string(), t.platfrom(&self.objects))))
.collect::<HashMap<_, _>>()
}
}

impl TryFrom<PBXHashMap> for PBXRootObject {
Expand Down

0 comments on commit 04a8732

Please sign in to comment.