Struct DeveloperDirectory

Source
pub struct DeveloperDirectory { /* private fields */ }
Expand description

A directory containing Apple platforms, SDKs, and other tools.

Implementations§

Source§

impl DeveloperDirectory

Source

pub fn from_env() -> Result<Option<Self>, Error>

Resolve an instance from the DEVELOPER_DIR environment variable.

This environment variable is used by convention to override default search locations for the developer directory.

If DEVELOPER_DIR is defined, the value/path is validated for existence and an error is returned if it doesn’t exist.

If DEVELOPER_DIR isn’t defined, returns Ok(None).

Source

pub fn from_xcode_select_paths() -> Result<Option<Self>, Error>

Attempt to resolve an instance by checking the paths that xcode-select --switch configures. If there is no path configured, this returns None.

This checks, in order:

  • The path pointed to by /var/db/xcode_select_link.
  • The path pointed to by /usr/share/xcode-select/xcode_dir_link (legacy, previously created by xcode-select).
  • The path stored in /usr/share/xcode-select/xcode_dir_path (legacy, previously created by xcode-select).

There are no sources available for xcode-select, so we do not know if these are the only paths that xcode-select uses. We can be fairly sure, though, since the logic has been reverse-engineered several times.

The exact list of paths that apple-sdk searches here is an implementation detail, and may change in the future (e.g. if xcode-select is changed to use a different set of paths).

Source

pub fn from_xcode_select() -> Result<Self, Error>

Attempt to resolve an instance by running xcode-select.

The output from xcode-select is implicitly trusted and no validation of the path is performed.

Source

pub fn default_xcode() -> Option<Self>

Attempt to resolve an instance from the default Xcode.app location.

This looks for a system installed Xcode.app and for the developer directory within. If found, returns Some. If not, returns None.

Source

pub fn find_system_xcodes() -> Result<Vec<Self>, Error>

Finds all Developer directories for system installed Xcode applications.

This is a convenience method for find_system_xcode_applications() plus resolving the Developer directory and filtering on missing items.

It will return all available Developer directories for all Xcode installs under /Applications.

Source

pub fn find_default() -> Result<Option<Self>, Error>

Attempt to find a Developer Directory using reasonable semantics.

This is probably what most end-users want to use for resolving the path to a Developer Directory.

This is a convenience function for calling other APIs on this type to resolve the default instance.

In priority order:

  1. DEVELOPER_DIR
  2. System Xcode.app application.
  3. xcode-select output.

Errors only if DEVELOPER_DIR is defined and it points to an invalid path. Errors from running xcode-select are ignored.

Source

pub fn find_default_required() -> Result<Self, Error>

Find the Developer Directory and error if not found.

This is a wrapper around Self::find_default() that will error if no Developer Directory could be found.

Source

pub fn path(&self) -> &Path

The filesystem path to this developer directory.

Source

pub fn platforms_path(&self) -> PathBuf

The path to the directory containing platforms.

Source

pub fn platforms(&self) -> Result<Vec<PlatformDirectory>, Error>

Find platform directories within this developer directory.

Platforms are defined by the presence of a Platforms directory under the developer directory. This directory layout is only recognized for modern Xcode layouts.

Returns all discovered instances inside this developer directory.

The return order is sorted and deterministic.

Source

pub fn sdks<SDK: AppleSdk>(&self) -> Result<Vec<SDK>, Error>

Find SDKs within this developer directory.

This is a convenience method for calling Self::platforms() + PlatformDirectory::find_sdks() and chaining the results.

Trait Implementations§

Source§

impl AsRef<Path> for DeveloperDirectory

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for DeveloperDirectory

Source§

fn clone(&self) -> DeveloperDirectory

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeveloperDirectory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Path> for DeveloperDirectory

Source§

fn from(p: &Path) -> Self

Converts to this type from the input type.
Source§

impl From<&PathBuf> for DeveloperDirectory

Source§

fn from(path: &PathBuf) -> Self

Converts to this type from the input type.
Source§

impl From<PathBuf> for DeveloperDirectory

Source§

fn from(path: PathBuf) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DeveloperDirectory

Source§

fn eq(&self, other: &DeveloperDirectory) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for DeveloperDirectory

Source§

impl StructuralPartialEq for DeveloperDirectory

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.