verifyos_cli/parsers/
xcode_parser.rs1use miette::Diagnostic;
2use std::path::Path;
3use thiserror::Error;
4use xcodeproj::XCodeProject;
5
6#[derive(Debug, Error, Diagnostic)]
7pub enum XcodeError {
8 #[error("Failed to read Xcode project at {path}")]
9 ReadError { path: String, description: String },
10}
11
12pub struct XcodeProject {
13 pub inner: XCodeProject,
14}
15
16impl XcodeProject {
17 pub fn from_path(path: impl AsRef<Path>) -> Result<Self, XcodeError> {
18 let path = path.as_ref();
19
20 let inner = XCodeProject::new(path).map_err(|e| XcodeError::ReadError {
21 path: path.display().to_string(),
22 description: format!("{e:?}"),
23 })?;
24
25 Ok(Self { inner })
26 }
27
28 pub fn target_names(&self) -> Vec<String> {
29 self.inner
30 .targets()
31 .iter()
32 .filter_map(|t| t.name.map(|s| s.to_string()))
33 .collect()
34 }
35}