Skip to content

Commit 7ca1076

Browse files
committed
feat(xcodeproj): expose root and set name
1 parent 04a8732 commit 7ca1076

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod xcode;
1616
/// Main presentation of XCodeProject
1717
#[derive(Debug, Default, derive_deref_rs::Deref)]
1818
pub struct XCodeProject {
19+
name: String,
1920
root: PathBuf,
2021
#[deref]
2122
pbxproj: PBXRootObject,
@@ -28,8 +29,30 @@ impl XCodeProject {
2829
let pbxproj_path = xcodeproj_folder.join("project.pbxproj");
2930

3031
Ok(Self {
32+
name: xcodeproj_folder
33+
.file_name()
34+
.and_then(|name| Some(name.to_str()?.split_once(".")?.0.to_string()))
35+
.unwrap(),
3136
root: xcodeproj_folder.parent().unwrap().to_path_buf(),
3237
pbxproj: pbxproj_path.try_into()?,
3338
})
3439
}
40+
41+
/// Get a reference to the xcode project's name.
42+
#[must_use]
43+
pub fn name(&self) -> &str {
44+
self.name.as_ref()
45+
}
46+
47+
/// Get a reference to the xcode project's root.
48+
#[must_use]
49+
pub fn root(&self) -> &PathBuf {
50+
&self.root
51+
}
52+
53+
/// Get a reference to the xcode project's pbxproj.
54+
#[must_use]
55+
pub fn pbxproj(&self) -> &PBXRootObject {
56+
&self.pbxproj
57+
}
3558
}

0 commit comments

Comments
 (0)