Skip to content

Commit 04a8732

Browse files
committed
feat: helper function to generate hashmap of target names and platform
1 parent d06cba8 commit 04a8732

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pbxproj/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ pub use object::*;
77
pub use value::*;
88

99
use anyhow::Result;
10-
use std::path::{Path, PathBuf};
10+
use std::{
11+
collections::HashMap,
12+
path::{Path, PathBuf},
13+
};
1114
use tap::Pipe;
1215

1316
/// `Main` Representation of project.pbxproj file
@@ -76,6 +79,14 @@ impl PBXRootObject {
7679
pub fn objects_mut(&mut self) -> &mut PBXObjectCollection {
7780
&mut self.objects
7881
}
82+
83+
/// Get a hashmap of targets and their platform
84+
pub fn targets_platform(&self) -> HashMap<String, PBXTargetPlatform> {
85+
self.targets()
86+
.into_iter()
87+
.flat_map(|t| Some((t.name?.to_string(), t.platfrom(&self.objects))))
88+
.collect::<HashMap<_, _>>()
89+
}
7990
}
8091

8192
impl TryFrom<PBXHashMap> for PBXRootObject {

0 commit comments

Comments
 (0)